HDTenEightyP/NetNews huggingface dataset:
From: friedman@chekov.UU.NET (Barry Friedman)
Newsgroups: comp.lang.perl
Subject: ckpl.pl : vi front end to perl -c
Keywords: error positioning
Date: 16 Apr 92 06:03:14 GMT
Reply-To: Barry.Friedman@bnr.ca
Organization: Northern Telecom, Ltd.


Here's a scrap of code that I would like to share with you:

It calls vi, positioning on the first error line detected.

Two files will be edited, the source file specified and perl -c's output.
By typing ":n", the error listing will be read in as the alternate file in 
vi which can be swapped using ":e#" or "=" if you're using Tom. C's. vi macros;

If some brave soul should care to complete the regular expression for
the rest of perl -c's error output, please add me to the distribution.

BTW, this regular expression gave me a bit of trouble until I added the
extra paren's around the alternations which otherwise didn't seem to
yield the expected results. Can anyone see why?


#!perl 
# ckpl.pl
# Usage:  ckpl.pl perlprog.pl
# Author:  friedman@bnr.ca

@files=@ARGV;
open ( INERRS,"sqerl -c @files 2>&1 |") || "die can't open INERRS"; 
open ( TMPOUT,">errs.$$") || "die can't open TMPOUT"; 

while(<INERRS>) {
	if (/((syntax error)|(runaway)|(Illegal division)).*((on line)|(at line)) (\d+)/
		)
	{
		print "1: $1 2: $2 3: $3 4:$4 5: $5 6:$6 7:$7 8:$8 9:$9\n" if $dbg;
		$errl=$8 unless $errl;
	}
	if(/compilation errors/) { $errs++; }
	print TMPOUT;
}
close (TMPOUT);

if ($errl) {
	system ("vi +$errl @files errs.$$") ;
} elsif ( $errs) {
	print "Errors Detected\n";
	system("cat errs.$$");
} else {
	print "No errors Detected\n";
	system("cat errs.$$");
	print;
}
unlink ("errs.$$");

--
Barry Friedman
From: marc@athena.mit.edu (Marc Horowitz)
Newsgroups: comp.lang.perl
Subject: Re: Is there a way to prevent perls auto-alloc-variable mechanism?
Date: 10 Apr 92 19:17:34 GMT
Article-I.D.: uvaarpa.1992Apr10.191734.2495
Reply-To: Marc Horowitz <marc@mit.edu>
Organization: The Internet

From the keyboard of wierda@ltb.ltb.bso.nl (Gerben Wierda):
:Suppose I have a associated array. Can I freeze this array in such a way that
:addressing any member not in the array will *not* create it?

Well, you need a function call for each refernce, but...

# put stuff in %foo
# ...

sub foo {
	$foo{$_[0]};
}

and use &foo("bar") to reference.  You get a compile error if you try
to use it as an lvalue.  If you have many such arrays, you can make
the function take an array name using pass-by-name.

		Marc
From: drw@nevanlinna.mit.edu (Dale R. Worley)
Newsgroups: comp.lang.perl
Subject: Re: novice q: finding unique words in a list
Date: 15 Apr 92 18:11:41 GMT
	<DRW.92Apr14114322@kronecker.mit.edu>
	<1992Apr14.171652.25723@news.eng.convex.com>
Organization: MIT Dept. of Tetrapilotomy, Cambridge, MA, USA

In article <1992Apr14.171652.25723@news.eng.convex.com> Tom Christiansen <tchrist@convex.COM> writes:
   Sort should be a primitive for two reasons: speed and convenience. 

Ah, yes.  But what I meant was that sort should be a primitive because
of speed and convenience considerations, not because it's "obvious"
that it should be.  But uniq can be written both quickly and
efficiently in Perl; sort can't.  That's why sort is a primitive but
uniq isn't.

Dale Worley		Dept. of Math., MIT		drw@math.mit.edu
--
I'd sign on for the War on Drugs if they'd include alcohol and
nicotine on the official hit list.
From: wierda@ltb.ltb.bso.nl (Gerben Wierda)
Newsgroups: comp.lang.perl
Subject: Memory problems using VROOM perl
Date: 9 Apr 92 10:06:40 GMT
Organization: BSO/LT, Baarn, The Netherlands

I get the error:

	Reallocation to large: 10000

What can I do about that? I have tried to minimize memory constraints of the
script (It will now not say Out of Memory! anymore, but this error is not such
a big improvement over that).

The program does not reach the print STATEMENT:

open (CODELIST,"codelist"); # read code list
while (<CODELIST>) {
  chop;
  ($code,$freq,$term) = split(/\t/); # split on tabs
  $CF{$code} = $freq; # note frequency of code
}
close(CODELIST);

open (STOPLIST,"stoplist"); # read stop list
while (<STOPLIST>) {
  chop;
  $StopWord{$_} = 1; # note stop word
}
close(STOPLIST);

$StartTime = time;
print STDERR "Indexering begint...\n";

Codelist looks like:

A	1	text text text
B	3	more text text text text text text text
C	1	some text
D	1	even more text like the previous lines

[deleted 1700 lines]

BMI	1	almost last text text text
BMJ	1	last text

-- 
wierda@ltb.bso.nl (Gerben Wierda) || I speak for myself and not for my employer.
(+31) 2154 84415/(+31) 35 833539  || Support the League for Programming Freedom!
	"If you don't know where you are going, any road will take you there."
	Lewis Carroll, "Alice in Wonderland".
Newsgroups: comp.lang.perl
From: navarra@casbah.acns.nwu.edu (John Navarra)
Subject: Question on how to use getopts.pl
Organization: Northwestern University, Evanston Illinois.
Date: Thu, 9 Apr 1992 20:33:05 GMT



	I need some help on how to use perl's getopts library. I have 
a program with many options that I want to process. For example, say
I have and option x which may or may not use option y as well:
i.e. program -x[y], how can I use getopts to do this in perl? I have
not seen any examples in the FAQ or nutshell book to do what I want.
Otherwise, I will have to make numerous tests for various combinations
of options like:
	
	if (/-x/) {
		do whatever 
	}
	elisif (/-xy/) {
		do whatever
 	}
	
 which tends to get tedious if you have a few of these. 

   Side question: Is perl's getopts faster in this case than if-elsif
   constructs? I am writing a script with about 12 or so different
   options and I am used to getopts or case statements. The if-elsif
   stuff is just habitually abhorent to me. 

Thanx for any help
-tms
 
-- 
From the Lab of the MaD ScIenTiST:
					
navarra@casbah.acns.nwu.edu		
Newsgroups: comp.lang.perl
From: rahardj@ccu.umanitoba.ca (Budi Rahardjo)
Subject: Re: Where to find compiled MSDOS PERL?
Organization: University of Manitoba, Winnipeg, Canada
Date: Fri, 10 Apr 1992 20:37:22 GMT

unikocp@uts.uni-c.dk (Ole Carsten Pedersen) writes:

>Is PERL for MSDOS available at any server site in compiled "plugh and play" 
>form?

Available from Simtel20 and its mirrors (oak.oakland.edu, wuarchive.
wustl.edu, etc.). It's msdos/perl/perl419x.zip or 
<msdos.perl>perl419x.zip

Also a whole bunch of MS-DOS perl from ftp.ee.umanitoba.ca in
pub/msdos/perl directory.

Have fun.
-- budi
-- 
Budi Rahardjo <rahardj@ccu.umanitoba.ca>
Unix Support - Computer Services - University of Manitoba
From: sherman@unx.sas.com (Chris Sherman)
Newsgroups: comp.lang.perl
Subject: sorting records
Date: 13 Apr 92 21:41:44 GMT
Organization: SAS Institute Inc.
X-Bytes: 1531

Yo Perl Dudes,

I have a question about sorting...

How does one sort records based on a value that can occur in more than
one record?

Here is an example: Suppose I want to find every word in a file, and sort
by word length, and print the words with their lengths, largest to
smallest. 

There may be maybe 1500 words, but only about 60 values associated with
those words, so there will be duplicate values.

while (<words>)     # assume one word per line for now
{
  $words{$word} = length($word);
}

Now what do you do?

print sort values %words?  Not.  There is no way to get the word back.

In C when I do sorting like this, I swap structure pointers, so all the
values in the structure get 'moved', not just the value being sorted.

One why I did come up with is the following.  This will find all
the words, multiple words per line.  Then it puts the length value and word
into one string, length first, and does a normal numeric sort, and prints.

#!/usr/local/bin/perl
undef $/;
$* = 1;
foreach (split(" ",<>))
{
  push(@words,length($_)." ".$_);
}
$/="\n";
print join("\n",sort {$b <=> $a;} @words);


Is there a better way?


ps.  On a side note, what is better:  'reverse sort' or 'sort {$b <=> $a}'?


Thanx!!!  (My apologies if this has been hashed to death before).
-- 
     ____/     /     /     __  /    _  _/    ____/
    /         /     /     /   /      /     /          Chris Sherman
   /         ___   /        _/      /          /
 _____/   __/   __/   __/ _\    _____/   _____/           sherman@unx.sas.com
Newsgroups: comp.lang.perl
From: drw@nevanlinna.mit.edu (Dale R. Worley)
Subject: Re: Problem with split
Organization: MIT Dept. of Tetrapilotomy, Cambridge, MA, USA
Date: Wed, 8 Apr 1992 22:25:09 GMT

In article <1992Apr7.151458.9129@fnbc.com> jja@amy (Joseph Alotta) writes:
   It seems like things I do often fail to work under certain circumstances.
   Can anyone tell me what the circumstances are that keeps this from  
   working?

     DB<22> p $i
	     16 920406       9205          4087        4140        4080
   4110        6657       41787 
     DB<23> p split(/ /,$i)
   1692040692054087414040804110665741787
     DB<24>        ($csi, $date, $expiry, $open, $high, $low, $close, $vol,  
   $oi) = split(/ /, $i);

You probably want to say split(/ +/, $i) -- as you wrote it, *each*
space is a separator, leaving about 8 null fields at the beginning of
split's value.  But if you have leading spaces, you'll still get one
null field at the beginning.

Dale Worley		Dept. of Math., MIT		drw@math.mit.edu
--
Tolerance isn't just about accepting that other people like things
that we dislike. It is also about accepting that some people *dislike*
things that we *like*. Even about ourselves.
From: saunders_j@cho006.cho.ge.com
Newsgroups: comp.lang.perl
Subject: script wanted: window grep
Date: 8 Apr 92 13:43:05 GMT
Article-I.D.: cho006.1992Apr8.094305.173
Organization: GE Fanuc Automation, North America

I hate to ask this, but I seem to have lost the window grep
script that was posted not too long ago. I tried to look around
on various machines for it, but I had no luck...

So, could someone please mail a copy of it to me? I'd really
appreciate it!

Thanks!
--
Jonathan Saunders <saunders_j@alb000.dnet.ge.com> |The opinions in this message
GE Fanuc, Albany, NY USONO (UTC-5) +1 518 464 4594|are the author's, and are
Mi lernas la internacian lingvon Esperanton por   |not those of GE Fanuc or
promocii pacon kaj internacian komprenadon!       |any other company or person.
From: krab@iesd.auc.dk (Kresten Krab Thorup)
Newsgroups: comp.lang.perl
Subject: Re: Syntax of delete
Date: 1 Apr 92 08:58:15 GMT
Organization: Mathematics and Computer Science, Aalborg University

Root Boy Jim wrote:

	I tried to write "delete($foo{'bar'});"
	
	Perl complained about the parens. Why?

The delete operation expects an lvalue as it's operand.  By enclosing
the $foo{'bar'} in parenthesis, you make it an rvalue, namely a list
with one element in it, the value of $foo{'bar'}.
	This list will be anonymous, ie only live on the runtime
stack, and hence, it makes no sense to delete it.

/Kresten
--
What you can't do idaw, maybe you can do imorn'
From: lukas@cbnewsc.cb.att.com (LUKAS)
Newsgroups: comp.lang.perl
Subject: Re: Help: searching, translating chars.
Date: 17 Apr 92 18:12:25 GMT
Distribution: usa
Organization: AT&T Network Systems - Lisle Illinois

In article <1992Apr10.175909.10398@netlabs.com> lwall@netlabs.com (Larry Wall) writes:

Just when I get to the point where I *think* that I know what-
is-going-on, you guys come up with something new:

>    $Month = "\u\L$month";

Could someone give me a camel or manpage reference (please-oh-
please let it be a new or undocumented feature, and so salvage
my shattered ego)? TIA.
-- 

	John Lukas
	att!{nwsca}!lukas
	708-224-6290
Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: why does this leak?
Originator: tchrist@pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Realtime Development, Colorado Springs, CO
Date: Thu, 16 Apr 1992 20:00:25 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 nagel@Cigna.COM (Mark Nagel):
:I wrote a simple script to hang around in the background and monitor
:our printers.  Problem is it keeps growing!  After some time it
:exceeds swap space.  I could get around this by having cron run it
:once per minute or something, but I'd like to find out whether I'm
:doing something wrong.

:	for $re (@ignore) {
:	    return if eval("\$s =~ /$re/");
:	}

Shooting from the hip, maybe try

 	for $re (@ignore) {
 	    return if $s =~ /$re/;
 	}

I'm not convinced that eval always cleans up everything properly, even
when it succeeds.

BTW, if speed were an issue, this could be made faster by creating a subr
on the fly built of all the re's and eval'ing it to create it just once,
then calling it normally when needed.

--tom
From: rampson@snakepit.uswest.com (Michael T. Rampson)
Newsgroups: comp.lang.perl
Subject: Re: Problem with split
Keywords: split,problem
Date: 8 Apr 92 14:35:21 GMT
Organization: U S WEST Information Technologies

In article <1992Apr7.151458.9129@fnbc.com>, jja@amy (Joseph Alotta) writes:
> It seems like things I do often fail to work under certain circumstances.
> Can anyone tell me what the circumstances are that keeps this from  
> working?
> 
> 
>   DB<22> p $i
>           16 920406       9205          4087        4140        4080         
> 4110        6657       41787 

You have a lot of white space before the number 16.  I am assuming these
are spaces and thus are getting put into the array that split returns
as null entries.  When you print out the null array (ie your p split
below), these don't take up any space on the screen (read unprintable)
and so it doesn't look like they are there.  Try splitting on
/[ ]+/ or /\s+/ instead.

>   DB<23> p split(/ /,$i)
> 1692040692054087414040804110665741787
>   DB<24>        ($csi, $date, $expiry, $open, $high, $low, $close, $vol,  
> $oi) = split(/ /, $i);
-- 
These opinions are my own and not anyone elses.  
rampson@uswest.com
-----------------------------------------------------------------------
"It took me 17 years to get 3,000 hits in baseball.  I did it in
one afternoon on the golf course." -- Henry Aaron.
From: lukas@cbnewsc.cb.att.com (LUKAS)
Newsgroups: comp.lang.perl
Subject: printf conflict with $#
Date: 17 Apr 92 17:39:30 GMT
Distribution: usa
Organization: AT&T Network Systems - Lisle Illinois

Can anyone explain why this simple program:

	$# = "%.6g";
	printf ("%15f", 43);
	print "\n";

produces for output:

	43

instead of the expected (and desired):

	      43.000000

(15 characters with leading spaces)? If I remove the reference
to $#, the program works ok. Why should setting $# affect printf?
BTW, setting $#, and then setting it back to its default of "%.20g"
does NOT return printf to a working state.
-- 

	John Lukas
	att!{nwsca}!lukas
	708-224-6290
Newsgroups: comp.lang.perl
From: mcook@mrc.dev.cdx.mot.com (Michael Cook)
Subject: Re: novice q: finding unique words in a list
Organization: Motorola Codex, Canton, Massachusetts
Date: Thu, 9 Apr 1992 13:00:04 GMT

spaf@cs.purdue.EDU (Gene Spafford) writes:

>Why not:

>sub uniq {
>    local(%unique);

>    grep(!$unique{$_}++, @_);
>}

That ain't exactly uniq(1):

     Description
          The uniq command reads the input file comparing adjacent lines.
          In the normal case, the second and succeeding copies of repeated
          lines are removed; the remainder is written on the output file.
          Note that repeated lines must be adjacent in order to be found.
          For further information, see sort(1).

The key word is "adjacent".
-- 
 ==========================================================
 Michael.Cook@merlin.dev.cdx.mot.com          (617)821-7590
 Motorola/Codex, 20 Cabot Blvd, C2-135, Mansfield, MA 02048
 ==========================================================
Newsgroups: comp.lang.perl
From: drw@nevanlinna.mit.edu (Dale R. Worley)
Subject: Forms system example
Organization: MIT Dept. of Tetrapilotomy, Cambridge, MA, USA
Date: Wed, 15 Apr 1992 18:20:20 GMT

A couple of people have written asking for an example of using my
forms package, so I've written one.  It may not be thoroughly
debugged, but it does work at least a bit.

require 'forms.pl';

# Generate the form
$r = &forms'process_representation(*screen, split(/\n/, <<'EOF'));
:
label_location = 1,25
label_text = Perform Computation

operand1:
label_location = 5,0
label_text = Operand 1
field_location = 5,10
field_length = 10
construct_displayed_value = @char_field
initialize_displayed_field = @id_cursor_after
validate_displayed_value = @true
interpret_displayed_value = @trim_trailing_space
insert = @text_insert
edit = @text_edit

operator:
label_location = 6,0
label_text = Operator
field_location = 6,10
field_length = 3
construct_displayed_value = @enum_field
initialize_displayed_field = @id_cursor_after
validate_displayed_value = @enum_validate
interpret_displayed_value = @enum_interpret
translate_table = add=add\sub=sub\mul=mul\div=div
insert = @text_insert
edit = @text_edit

operand2:
label_location = 7,0
label_text = Operand 1
field_location = 7,10
field_length = 10
construct_displayed_value = @char_field
initialize_displayed_field = @id_cursor_after
validate_displayed_value = @true
interpret_displayed_value = @trim_trailing_space
insert = @text_insert
edit = @text_edit

MSG:
field_location = 23,0
field_length = 79
construct_displayed_value = @char_field
initialize_displayed_field = @id_cursor_after
read_only = 1

EOF
die "Bad form: $forms'error" unless $r;

if (&forms'process_form(*screen)) {
    $a = $screen{'operand1', 'value'};
    $b = $screen{'operand2', 'value'};
    $op = $screen{'operator', 'value'};
    if ($op eq 'add') {
	$result = $a + $b;
    } elsif ($op eq 'sub') {
	$result = $a - $b;
    } elsif ($op eq 'mul') {
	$result = $a * $b;
    } elsif ($op eq 'div') {
	$result = $a / $b;
    }
    print "Result is $result\n";
}

Dale Worley		Dept. of Math., MIT		drw@math.mit.edu
--
I leave my entire estate to my wife on the condition that she shall
remarry, so there will be at least one man who regrets my death.
-- from the will of Heinrich Heine
From: wierda@ltb.ltb.bso.nl (Gerben Wierda)
Newsgroups: comp.lang.perl
Subject: Is there a way to prevent perls auto-alloc-variable mechanism?
Date: 9 Apr 92 11:16:15 GMT
Organization: BSO/LT, Baarn, The Netherlands

Suppose I have a associated array. Can I freeze this array in such a way that
addressing any member not in the array will *not* create it?

$aap{noot} = "aap";
$aap{mies} = "mies";

freeze;

$aap{wim}
	gives 0 in integer and "" in string context and gives error when used
as lvalue or something like that

New feature?
-- 
wierda@ltb.bso.nl (Gerben Wierda) || I speak for myself and not for my employer.
(+31) 2154 84415/(+31) 35 833539  || Support the League for Programming Freedom!
	"If you don't know where you are going, any road will take you there."
	Lewis Carroll, "Alice in Wonderland".
Newsgroups: comp.lang.perl
From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
Subject: Multiple pipes elegantly in Perl??
Keywords: pipe perl
Organization: Computer Science, University of Melbourne, Australia
Date: Thu, 16 Apr 1992 23:09:49 GMT

I'm fairly new to Perl, and I was wondering if there is an easy way to
do multiple pipes where you need to control both ends of the pipe.

For example, in "sh" you can do

	for var in $list
	do `process $var`
	done |

	some_other_process | sort | uniq |

	while read line
	do    finish_with $line
	done

From my reading of the manual, it would seem that to do this in Perl is tricky
and painful and involves explicitly creating a pipe, forking, testing to see
whether the fork succeeded, and if so whether you are in the child or the
parent, and so on.

Is there a better way?

Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: Help: searching, translating chars.
Originator: tchrist@pixel.convex.com
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Realtime Development, Colorado Springs, CO
Distribution: usa
Date: Fri, 17 Apr 1992 19:00:06 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 lukas@cbnewsc.cb.att.com (LUKAS):
:In article <1992Apr10.175909.10398@netlabs.com> lwall@netlabs.com (Larry Wall) writes:
:
:Just when I get to the point where I *think* that I know what-
:is-going-on, you guys come up with something new:
:
:>    $Month = "\u\L$month";
:
:Could someone give me a camel or manpage reference (please-oh-
:please let it be a new or undocumented feature, and so salvage
:my shattered ego)? TIA.

That's just normal /usr/ucb/vi case-translation escapes, included,
I suspect, at the behest of your truly.  In the man page, see the part
on backslash escapes:

    String literals are delimited by either single or double quotes.  They
    work much like shell quotes:  double-quoted string literals are
    subject to backslash and variable substitution; single-quoted strings
    are not (except for \' and \\).  The usual backslash rules apply for
    making characters such as newline, tab, etc., as well as some more
    exotic forms:

        \t             tab
        \n             newline
        \r             return
        \f             form feed
        \b             backspace
        \a             alarm (bell)
        \e             escape
        \033           octal char
        \x1b           hex char
        \c[            control char
        \l             lowercase next char
        \u             uppercase next char
        \L             lowercase till \E
        \U             uppercase till \E
        \E             end case modification


In the bottom of the man page, you also find what didn't make the book:

    ERRATA AND ADDENDA
	In double-quote context, more escapes are supported: \e, \a, \x1b,
	\c[, \l, \L, \u, \U, \E.  The latter five control up/lower case
	translation.

--tom
Newsgroups: comp.lang.perl
From: chare@unilabs.uucp (Chris Hare)
Subject: using SIG{'ALRM'}
Organization: None: Just Me, Chris Hare
Date: Tue, 7 Apr 1992 15:29:18 GMT

I have a program in which I want to use the alarm call and have it perform
a specific function.  However, I need to be sensitive to a couple of
things:

	1 - this is a curseperl program, so I need to be sensitive to when I am
	updating the screen so that operation is not interrupted.

	2 - I would like to return to the place the code was at when the signal
	was received.


	Is this possible, and how do I do it?

	Thanks for the help.


-- 
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Chris Hare				UUCP : uunet.ca!choreo!unilabs!chare
SCO Authorized Instructor		Choreo Systems Inc., Ottawa Canada
*** STANDARD DISCLAIMER APPLIES ***	DOMAIN: chare@choreo.ca
From: fenner@jazz.psu.edu (Bill Fenner)
Newsgroups: comp.lang.perl
Subject: Re: Proposal: Interactive Perl Tutorial
Date: 7 Apr 92 19:37:54 GMT
Organization: Penn State University Mechanical Engineering

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.

|But it won't be the first time we've been ignored.  

Whining doesn't tend to make people listen to you.

--
Bill Fenner	fenner@jazz.psu.edu	..psuvax1!hogbbs!wcfpc!wcf
		wcf@hogbbs.scol.pa.us   (+1 814 238-9633 v.32bis)
Newsgroups: comp.lang.perl