HDTenEightyP/NetNews huggingface dataset:
From: hsc@stroid.sybase.com (Howard Cohen)
Newsgroups: comp.lang.perl
Subject: an FAQ ?
Summary: Need FAQ, and opinions
Keywords: FAQ
Date: 6 Apr 92 18:57:24 GMT
Followup-To: hsc@sybase.com
Organization: Sybase, Inc.

Hi all.  I've just finished reading the last 250 or so articles in this
newsgroup, and I would very much like a chance to read the FAQ.  Will some
kind soul mail the latest one to me at "hsc@sybase.com" ?  Thanks.

Now a request for opinions.  I have already posted to comp.unix.shell, and
have had some good replies (including pointing me to this group).  I am
in a position to perform research for Sybase to help determine what a
suitable language would be for implementing engineering-wide
tools.  Sybase needs these tools to run on not only Unix, but also VMS, DOS,
OS/2, and others. As such, none of the Unix-only shells (sh, csh, ksh, etc.)
are really viable choices.  Wide portability is the issue here.

So far, the only viable choices appear to be C and perl (possibly perl with
some specialized code written in C, and linked with perl).  

	1) How feasible is it to commit to perl (possibly with some C) as
	   the foundation for engineering tools? Have you experienced
	   problems that would compromise such a project?  How about the
	   political aspect (corporate politics)?  Am I in for a major battle
	   with upper management if I stand behind perl?  My fanny will be 
	   on the line if I push for perl and it ends up being a fiasco.
	   I don't wan't my fanny on the line, but I also don't want to pick
	   an inferior approach just because its more easily defensible.

	2) What alternatives exist?  I can't find any that offer wide
	   portability (unless I'm willing to do the porting of a Unix-centric
	   system).

	3) Clearly, most of you use perl, and either like it or find it
	   acceptable. Do you think its feasible to create complex tools
	   like a build system (i.e. something like make), or souce access
	   tools (a network based front end for SCCS) in perl?  The language
	   is complex, but are complex applications feasible to create and
	   maintain?

	4) Finally, working at Sybase and all, if we (my team) embrace perl, 
	   then clearly we will want to also embrace sybperl.  The combination
	   is particularly convenient for us.  Do any of you have much
	   experience with it?  Good?  Bad?  Ugly?  If we do embrace it,
	   then sybperl users may find an ally here.

I was very impressed with the level of expertise of the people who posted
answers to this group.  For me, the quality of this newsgroup is one 
argument in favor of embracing perl.  However, it is not an easy decision,
and I want as much (relevant) information as possible before any committment 
is made.

Thank you for your consideration,

	Howard
-------------------------------------------------------------------------------
  Howard "I wood if I could" Cohen
  hsc@sybase.com  {pacbell,pyramid,sun,{uunet,ucbvax}!mtxinu}!sybase!hsc
  Sybase, Inc.    6475 Christie Avenue, Emeryville, CA 94608, 510-596-3406
From: jfh@netcom.com (Jack Hamilton)
Newsgroups: comp.lang.perl
Subject: Re: Proposal: Interactive Perl Tutorial
Date: 8 Apr 92 03:18:31 GMT
Article-I.D.: netcom.rnqjt_d.jfh

In article <1992Apr7.153800.3883@ecl.psu.edu> fenner@jazz.psu.edu (Bill 
Fenner) writes:
>In article <5fpj!8.jfh@netcom.com> jfh@netcom.com (Jack Hamilton) writes:
>|One problem is that it probably won't help MS-DOS users, since we don't
>|have curseperl.
>
>And whose fault is that?  Grab swears, or some other MS-DOS curses
>implementation, and compile curseperl with it.

There's a certain type of perl snob, of which you are apparently one, who
thinks that perl should only be used by Unix/C wizards, and other people
don't deserve to be able to use it.

Saying "buy a C compiler and get the swears sources and the perl sources
and learn enough C and MS-DOS internals to make it all work", which is what
you are suggesting, is analogous to saying "You want a car?  Here
are the parts."  I don't want to make the thing, I just want to use it.  

When I first starting using perl, what I heard from people was that I
couldn't learn perl if i didn't know c.  That has not turned out to be
true.  I think some perl users overestimate its difficulty.  I'm not sure
why that would be, unless they just think they're more intelligent than
other people.  (The man page and the camel book do not reflect this
attitude, by the way.  they could use some fleshing out in the areas
derived from c, but they're easy to read and convey a lot of information.)

perl really is a good language, you know.  It's very powerful, and it's not
that difficult to use.

>|But it won't be the first time we've been ignored.  
>
>Whining doesn't tend to make people listen to you.

OK, what would you suggest (other than doing it myself)?  

-- 

------------------------------------
Jack Hamilton         jfh@netcom.com
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: initting vars inside -n scripts
Keywords: -n variables
Date: 10 Apr 92 01:48:20 GMT
Organization: NetLabs, Inc.

In article <1691@toro.MTS.ML.COM> scott@toro.MTS.ML.COM (Scott Strool) writes:
: When invoking perl scripts with '-n' your script is wrapped with:
: while (<>) {
:  ..here is your script..
: }
: If you set variables in your script they too will be wrapped in the while
: loop. Is there a way to avoid this and still use -n, or is the solution
: to explicitly add the while loop myself and leave off -n.

Well, you could say

	&initvars if $. == 1;
	whatever...

	sub initvars {
	    $foo = 1;
	    $bar = 2;
	}

but it's easier and more efficient to just write the while loop if you
need it.  It's not as if it's that many more characters to type than
BEGIN {}, which is kind of a crock anyway.

Larry
Newsgroups: comp.lang.perl
From: loren@netcom.com (Loren Hart)
Subject: Re: Converting Perl to x
Date: Fri, 10 Apr 92 04:22:04 GMT
Organization: Netcom - Online Communication Services  (408 241-9760 guest) 

olson@mcs.anl.gov (Bob Olson) writes:
: This brings up something that I've been thinking about for a while.
: What we could do is define 'Pidgin Perl': that subset of perl that is
: easy to compile. We would need to
: 
:     o	Regularize the syntax to make it easy to parse 
: 	(require parens around all function invocations, say)
:     o	Disallow eval
:     o	Disallow s///e and anything else that wants to use eval
:     o	Place strict restrictions on the use of lexically scoped
: 	variables; perhaps requiring that all variables are either
: 	globally or locally declared (globally declared meaning
: 		&Pidgin'DeclareGlobal(varname)
:     o	And whatever else makes it difficult to compile to C.
: 
: I claim what we would have left would still be a quite useful
: langauge, especially since you could still do the development in Perl,
: only compiling down to C when needed.
: 
: --bob

I've been thinking about this myself.  We could even write it in Pidgin
Perl, and compile it using itself!  I'd be interested in working on
such a project.

-- Loren


-- 
=============================================================================
Mr Loren L. Hart                                       The Ada Ace Group, Inc
loren@netcom.com                                       P.O. Box 36195
				                       San Jose, CA  95158
Newsgroups: comp.lang.perl
From: utashiro@InterTech.COM (Kazumasa Utashiro)
Subject: Re: Malloc problems in perl
Organization: InterTech Data Systems, Inc., Cupertino, CA
Date: Tue, 7 Apr 1992 17:59:27 GMT

In article <1992Apr5.072818.4196@acsu.buffalo.edu>
	ajay@acsu.buffalo.edu (Ajay Shekhawat) writes:
 >I'm using Kazumasa Utashiro's Multi-line Grep (mg), posted here
 >a few days ago. It's a neat script, but it is giving me a "Bus Error"
 >when I do a recursive grep on a large number of files, and there are
 >a few matches.
 >This is perl, version 4.0
 >Patch level: 10

I got a segmentation fault on our IPX with perl4.010 too.
But there is no problem with perl4.019 compiled with system
standard malloc.  I tried it for whole /usr directory.  So
updating your perl to 4.019 will solve the problem.

--utashiro
From: spaf@cs.purdue.EDU (Gene Spafford)
Newsgroups: comp.lang.perl
Subject: Re: novice q: finding unique words in a list
Date: 11 Apr 92 16:59:12 GMT
	<18400@ector.cs.purdue.edu> <1992Apr10.232126.15931@InterTech.COM>
Organization: Department of Computer Science, Purdue University

In article <1992Apr10.232126.15931@InterTech.COM>
utashiro@InterTech.COM (Kazumasa Utashiro) writes about my second "uniq:

> This works fine as long as grepping from \n terminated
> lines.  But doesn't work for arbitrary strings.

Huh?  My solution, 

    sub uniq {
	local($previous) = undef;

	grep((($_ ne $previous) && ($previous = $_, 1)), @_);
    }

Works on arbitrary strings, \n terminated or not.  The "ne" operation
does character-by-character comparison for equality.  As the "memory"
variable gets set to "undef" it will not match any first entry in the
argument array, \n terminated or not.
-- 
Gene Spafford
Software Engineering Research Center & Dept. of Computer Sciences
Purdue University, W. Lafayette IN 47907-1398
Internet:  spaf@cs.purdue.edu	phone:  (317) 494-7825
Newsgroups: comp.lang.perl
From: deng@bnl.gov (dp)
Subject: A script to find the most reliable return address from email
Organization: ().:.()
Distribution: comp
Date: 7 Apr 92 17:25:49

I am looking for a perl that can find the most reliable return addresses from
email messages. Is there such a beast?

Thanks.

Dong-Ping
Newsgroups: comp.lang.perl
From: utashiro@InterTech.COM (Kazumasa Utashiro)
Subject: Re: Highlit fields in 'format' fields
Organization: InterTech Data Systems, Inc., Cupertino, CA
Date: Thu, 16 Apr 1992 18:53:34 GMT

In article <1992Apr16.092421.322@abekrd.co.uk>
	garyb@abekrd.co.uk (Gary Bartlett) writes:
>
>I  am  using  format/write  for a report I am generating and I would now
>like to highlight certain fields using the man/more/less `convention' of
>using backspace sequences,
>
>	e.g.	Bold text:	B\bBO\bOL\bLD\bD
>		Underlined:	_\bU_\bn_\bd_\be_\br
>
>Strings that have had this highlighting applied to them triple in length
>but  the  space  taken up on screen remains the same (and certain pagers
>convert  this  information  into  different fonts).  Unfortunately, perl
>does  not  take into account the length on screen of these fields (which
>may  or  may  not  be a good thing) and so the following two results are
>seen.   Firstly, if the highlit field is longer than the field width the
>field  is  truncated  and secondly the following fields on the same line
>end up shifted to the left due to the backspaces.

As Tom said, there is no way to handle backspace character
in format.  So you have to print it by print function or
postprocess formated output.  If you handle the output,
multi-line output including highlighted words will be pretty
hard part.

You can use fold() routine in my sdif command to do this.
Next example demonstrates how the routine works.  It's a
almost clone of fold(1) command.  Some changes are necessary
for folding on word boundary.  You probably don't need
Japanese multi-byte character handling.

--utashiro

#!/usr/local/bin/perl
while(<>) {
	chop;
	do {
		($l, $_) = &fold($_, 40);
		print $l, "\n";
	} while (length);
}

sub fold {
    local($_, $width, $pad) = @_;
    local($l, $room) = ('', $width);
    local($n, $c, $r);
    while (length) {
	if (s/^\010//) {
	    ($room < $width) && $room++; $c = $&; next;
	} elsif (s/^\r//) {
	    $c = "\010" x ($width - $room);
	    $room = $width;
	    next;
	}
	last if !$room || (/^[\200-\377]/ && $room < 2);
	if (($mb = s/^([\200-\377].)+//) || s/[^\b\r\200-\377]+//) {
	    $n = $room; $n -= $room % 2 if $mb;
	    ($c, $r) = unpack("a$n a*", $&);
	    $room -= length($c);
	    $_ = $r . $_;
	} else {
	    die 'panic';
	}
    } continue {
	$l .= $c;
    }
    $l .= ' ' x $room if $pad;
    ($l, $_);
}
__END__

p.s. There was a bug on last release of sdif(v1.9). This is the fix.

215c215
< 	last if !$room || (/^[200-\377]/ && $room < 2);
---
> 	last if !$room || (/^[\200-\377]/ && $room < 2);
Newsgroups: comp.lang.perl
From: drw@nevanlinna.mit.edu (Dale R. Worley)
Subject: Fun with curseperl
Organization: MIT Dept. of Tetrapilotomy, Cambridge, MA, USA
Date: Thu, 9 Apr 1992 21:06:58 GMT

curseperl turned out to have an ugly problem.  The following program
does not do what is expected (clear the screen) when $ARGV[0] is true:

    $ENV{'TERM'} = 'vt100';
    &initscr;
    if ($ARGV[0]) {
	    &getcap('k1');
	    &getcap('k2');
	    &getcap('k3');
	    &getcap('k4');
    }

    &clear;
    &refresh;
    &getch;

(This is using BSD curseperl on a Sun4 with SunOS 4.1.1)

After probing around a bit, I came to suspect that the &getcap's
clobber something important inside curses, probably where it stores
the 'cl' string.  Looking at the machine code for curses getcap
(yuck), leads me to believe that getcap is just a wrapper for
termcap's tgetstr, *using a fixed internal buffer to collect the
results from tgetstr*.  It appears that this internal buffer has a
finite size, and each successive return value is written after the
previous one, so if you do a few too many getcap's, you write off the
end of the buffer...

A solution which appears to work is to change the interface for
&getcap to call tgetstr directly, but to supply a new buffer each
time.  I'd be real pleased if someone who knows how to use curses for
real would check that this code is OK.

*** bsdcurses.mus.old	Thu Apr  9 16:40:41 1992
--- bsdcurses.mus	Thu Apr  9 16:41:18 1992
***************
*** 476,484 ****
  CASE int erasechar
  END
  
! CASE char* getcap
! I	char*		str
! END
  
      case US_getyx:
  	if (items != 3)
--- 476,493 ----
  CASE int erasechar
  END
  
!     case US_getcap:
! 	if (items != 1)
! 	    fatal("Usage: &getcap($str)");
! 	else {
! 	    char* retval;
! 	    char*	str =		(char*)		str_get(st[1]);
! 	    char output[50], *outputp = output;
! 
! 	    retval = tgetstr(str, &outputp);
! 	    str_set(st[0], (char*) retval);
! 	}
! 	return sp;
  
      case US_getyx:
  	if (items != 3)

Dale Worley		Dept. of Math., MIT		drw@math.mit.edu
--
Take your dying with some seriousness, however.  Laughing on the way to
your execution is not generally understood by less advanced life forms,
and they'll call you crazy.
-- "Messiah's Handbook: Reminders for the Advanced Soul"
From: cro@socrates.ed.asu.edu (C. R. Oldham)
Newsgroups: comp.lang.perl
Subject: Insecure dependency in termcap.pl
Keywords: insecure dependency termcap.pl suid
Date: 9 Apr 92 17:35:12 GMT
Organization: North Central Association, Commission on Schools

I have written a pretty extensive conferencing system in Perl based
on the regular Usenet News that everyone is used to, but this system
resides on a single machine and provides some more varied options
to exclude reading and posting to certain conferences.  Anyway,
it is termcap-based, and one of the utilities (the newsreader, called
confer.pl) is invoked from a suid C wrapper.  The wrapper is suid to
root.

My problem is that when the utility is invoked from certain terminals
(notably from inside an OpenWindows shelltool), it complains with

Insecure dependency in eval at /usr/local/lib/perl/termcap.pl line 49.

That section of code in termcap.pl looks like this

...much deleted above...
    if ($TERMCAP =~ m:^/:) {
	$entry = '';
	do {
	    $loop = "
	    open(TERMCAP,'<$TERMCAP') || die \"Can't open $TERMCAP\";
	    while (<TERMCAP>) {
		next if /^#/;
		next if /^\t/;
		if (/\\|$TERM[:\\|]/) {
		    chop;
		    while (chop eq '\\\\') {
			\$_ .= <TERMCAP>;
			chop;
		    }
		    \$_ .= ':';
		    last;
		}
	    }
	    close TERMCAP;
	    \$entry .= \$_;
	    ";
	    eval $loop;
	} while s/:tc=([^:]+):/:/ && ($TERM = $1);
	$TERMCAP = $entry;
    }
...much deleted below...

Perl is new to me, though I have learned quite a bit while writing this
project.  It's about 3000 lines of Perl code.  Can someone enlighten
me as to how I might fix the problem?  Setting $> = $< before
including termcap.pl doesn't help, and I really don't know where
to go from here.

Thanks,


Charles R. (C. R.) Oldham | North Central Association, Commission on Schools
cro@socrates.ed.asu.edu or| Arizona State University, Tempe, AZ 85287-3011
aocro@acvax.inre.asu.edu  | 602/965-8700:800/525-9517 | #include <disclaimer.h>
"For the Lord is a great God, and a great King above all gods..." Psalm 95:3
From: gdha@se.alcbel.be (Gratien D'haese)
Newsgroups: comp.lang.perl
Subject: makelib missing
Date: 10 Apr 92 08:02:05 GMT
Reply-To: gdha@se.alcbel.be
Organization: Alcatel Bell, Antwerpen, Belgium


Dear Netters,
	I'm using the perl-4.0-18 version on Ultrix and Sun/OS, and I have the 
sources. But it seems that I'm missing the "makelib" program. Should this
normally be included or is it optional? And where can I find this program ?
Thanks.
--
  _______ 		Gratien D'haese    Switching Systems Division  se121
  \     /Alcatel			  F. Wellesplein 1, B-2018 Antwerpen
   \   /  Bell		e-mail: gdha@se.alcbel.be    Phone: (32) 3 240 94 51
    \/ Telephone		gdha@alcbel.be 	     Fax:   (32) 3 240 99 50
Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: sprintf problems
Originator: tchrist@pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Realtime Development, Colorado Springs, CO
Date: Mon, 13 Apr 1992 23:04:24 GMT
X-Disclaimer: This message was written by a user at CONVEX Computer
              Corp. The opinions expressed are those of the user and
              not necessarily those of CONVEX.

From the keyboard of chare@unilabs.uucp (Chris Hare):
:I have a program which is very data driven.  I read a user supplied
:configuration file which is used to describe the file which I am about to 
:transform.
:
:The input side is Ok, but the output definition may involve padding or
:truncatiing.  The length of the field is provided for in an array,
:
:	$OutputFieldLength[$FieldNum]
:
:How do I get the value of this element into an sprintf string, so that my
:field is of the appropriate width?
:
:	$Text = eval" sprintf( '%$lens', $value );";
:
:Doesn't seem to work.  If it is suppossed to, then I'll go back and make
:sure again I have all of the variables stuffed with the values I think they
:are.

Eval is too much work; try something more like

    $Text = sprintf("%{len}s", $value);

or merely

    $Text = substr($value, 0, $len); 

or you could perhaps use formatted writes.

--tom

Newsgroups: comp.lang.perl
From: cluther@morticia.cnns.unt.edu (Clay Luther)
Subject: I need to set up an array of file pointers.  No can do, so far.
Organization: University of North Texas
Date: Mon, 13 Apr 1992 17:54:59 GMT


Hello Perl-Land:

I have a program that must deal with several files with mechanically derived
names.  I would like to open the files and store the file pointers in an array.

Here is a snippet from my current code:

@FILEPTRS = ();
for ($i=o;$i<$NUMFILES;$i++) {
  $file = $ARVG[0] . ($i+1) . $EXT;
  if (open($FILEPTRS[$i],"<$file")) { ... }
  else { ... }
}
...
while ($go) {
  for ($i=0;$i<$NUMFILES;$i++) {
    $line = <$FILEPTRS[$i]>;       ## This does not work  
    ...
  }
}

In the code above, $line is never set.  A simple test

while (<$FILEPTRS[$i]>) { print; }

also doesn't do anything.

Have I just found a problem with perl?  That is, the inability to store
file pointers in an array?  Or have I not examined the problem deeply enough?

Your help appreciated.   Thanks.



-- 
Clay W. Luther                  cluther@morticia.cnns.unt.edu
System Manager                  Center for Network Neuroscience
University of North Texas       PO Box 5218 Denton, Texas 76203
817/565-3896,3472               aka. Malraux@GodNet (Bushashuru!)
From: jjsf@gmv.es (Julio Sanchez)
Newsgroups: comp.lang.perl
Subject: small ndbm files are not properly updated at close time
Date: 7 Apr 92 09:10:44 GMT
Organization: Grupo de Mecanica del Vuelo, S.A. (GMV), Madrid, Spain

I have a small associative array that is mapped to a ndbm file. I find
that some updates to pre-existing entries are not recorded in the file. 
If I create fake entries in my array, then everything seems OK. I have
not determined the exact limit, but 13 or 14 look like a good estimate.
As soon as I have more than those entries, everything works.

This was with 4.0.3, so I patched perl up to 4.0.19 and the problem
persists. This is a Sun 4/470 running SunOS 4.1.2 and I think perl
is using the ndbm routines though the way it is organized in SunOS
and perl looks rather confusing to me (config.h says HAS_NDBM and
inspection of perl seems to indicate that it will use the ndbm 
routines in that case).

The key that is not correctly updated is '#KEYS#', in case you find it
interesting. I dump the associative array and it has the updated
value, but after dbmclose and exit, the disk file has still the old
value for that key. I have not found the problem with the other keys,
but I have no evidence that the problem does not happen too.

Is this a known problem?

Julio
-- 
Julio Sanchez, GMV SA, Isaac Newton s/n, PTM Tres Cantos, E-28760 Madrid, Spain
Ph. +34 1 807 21 85 | jsanchez@gmv.es                 | Traveller, there is no
Fax +34 1 807 21 99 | jsanchez%gmv.es@Spain.EU.net    | path; paths are made by
Telex  48487 GMEV E | Julio_Sanchez_GMV@EuroKom.ie    | walking (A. Machado)
Newsgroups: comp.lang.perl
From: jbotz@sophia.smith.edu (Jurgen Botz)
Subject: Re: looking for a C parser
Organization: Smith College
Date: Thu, 9 Apr 1992 14:31:26 GMT

In article <DRW.92Apr8172620@nevanlinna.mit.edu> drw@nevanlinna.mit.edu (Dale R. Worley) writes:
>In article <mcook.702688464@mrc.dev.cdx.mot.com> mcook@mrc.dev.cdx.mot.com (Michael Cook) writes:
>   Does anyone have a Perl program that can parse ANSI C source?  
>
>No.
>
>Parsing ANSI C exactly correctly is a real bitch.  To do it correctly,
>you will almomst certainly have to buy a commercial parser.

Commercial?  Never!  GNU C is ANSI C, as good as and more portable
than any commercial compiler, free, and full sources available.

Support the FSF!
--
Jurgen Botz, jbotz@mtholyoke.edu
From: c21dsg@kocrsv01.delcoelect.com (Dianne Glickfield)
Newsgroups: comp.lang.perl
Subject: write and something other than STDOUT
Date: 13 Apr 92 18:54:39 GMT
Distribution: usa
Organization: Delco Electronics Corp.


Pardon Me if I have missed something blantantly obvious, but I'm having trouble
sending my report to a file.  Everything works fine if I use STDOUT. I have
the following:

    open(OUTFILE,'>> $outfile') || die "Could not open $!\n";
# Some processing
    write(OUTFILE);
    close OUTFILE;

format top =

                 My Attempt at a Report
__________________________________________________________
.

format OUTFILE =
   Some Variable: @<<<<<<<<<<<<<  Yet Another: @<<<<<<<<<<<<<<
		  $var1,			$var2
.


I'm sure there is something very simple that I'm just missing.  Any help is
greatly appreciated.  Thanks.


-- 
Dianne Glickfield
EDS/Delco Electronics	Internet:  c21dsg@kocrsv01.delcoelect.com
700 E. Firmin   CT10E	UUCP:	deaes!c21dsg
Kokomo, In  46902	Phone:	(317)451-0904   GMNet: 8-322-0904
From: scott@toro.MTS.ML.COM (Scott Strool)
Newsgroups: comp.lang.perl
Subject: Programming Perl Version
Keywords: book printing
Date: 8 Apr 92 19:37:48 GMT
Organization: Merrill Lynch Municipal Analytics & Systems, NY

I have Programming Perl First printing Jan 1991:

 Has an upgrade been published, if so how new is 
 it. Does anybody know if there are plans for
 a book update.