HDTenEightyP/NetNews huggingface dataset:
From: @prism.cs.orst.edu
Newsgroups: comp.lang.perl
Subject: Why doesn't this work?
Date: 2 Sep 92 19:10:14 GMT
Distribution: usa
Organization: Oregon State University, Computer Science Dept

Why doesn't this work?

   while ( ($eval) = ($path =~ /(\`.*\`)/) ) {
      $val = "";
      if ( $eval ) {
         $val = eval( $eval );
         chop $val;
      }
      $path =~ s/$eval/$val/;
   }


Here's what's happening via the debugger:

main'(explode:168):   while ( ($eval) = ($path =~ /(\`.*\`)/) ) {
  DB<2> print $path
Researchers/`echo David D. Perkins--071160 | cut -f1 -d-`/Fungi/collection_rec
  DB<3> s
main'(explode:169):      $val = "";
  DB<3> s
main'(explode:170):      if ( $eval ) {
  DB<3> p $eval
`echo David D. Perkins--071160 | cut -f1 -d-`
  DB<4> s
main'(explode:171):         $val = eval( $eval );
  DB<4> s
main'((eval):1):        `echo David D. Perkins--071160 | cut -f1 -d-`;
((eval):2):     ;
  DB<4> s
main'(explode:172):         chop $val;
  DB<4> s
main'(explode:174):      $path =~ s/$eval/$val/;
  DB<4> p $val
David D. Perkins
  DB<5> p $eval
`echo David D. Perkins--071160 | cut -f1 -d-`
  DB<6> p $path
Researchers/`echo David D. Perkins--071160 | cut -f1 -d-`/Fungi/collection_rec
  DB<7> s
main'(explode:168):   while ( ($eval) = ($path =~ /(\`.*\`)/) ) {
  DB<7> p $path
Researchers/David D. Perkins| cut -f1 -d-`/Fungi/collection_rec



Can someone help me out here?  It seems that nothing after the "|"
is being replaced.  What I had hoped would be in $path is
Researchers/David D. Perkins/Fungi/collection_rec
But that's not happening.  Any help would be appreciated...


--
Rebecca Jacobsen
rydenb@cs.orst.edu
Microbial Germplasm Database Project
Newsgroups: comp.lang.perl
From: ccechk@nuscc.nus.sg (Heng Kek)
Subject: Error in JAPH.
Organization: National University of Singapore
Date: Mon, 24 Aug 1992 04:02:33 GMT

Out of curiosity, I tried out one of Randal's recent JAPH's:

print unpack('@2a@15a@13a@14a@0a@4a@10a@11a@14a@7a@6a@12a@0a@3a@6a@12a@9a@0a@7a@4a@5a@8a@6a@12a@1a', ' ,JPacehklnorstu');

which resulted in the following diagnostic:

@ outside of string at d09 line 5.

("line 5" is the line containing the JAPH)
Further 'testing' revealed that:

print unpack('@11a@12a@1a', ' ,JPacehklnorstu');
print unpack('@11a@9a@1a', ' ,JPacehklnorstu');

gave the same error, but:

print unpack('@11a', ' ,JPacehklnorstu');
print unpack('@8a@9a@1a', ' ,JPacehklnorstu');

works.  Seems to have something to do with the number of digits in
the repeat count for '@'.  Is this a feature/bug?

Heng Kek
This is perl, version 4.0
$RCSfile: perl.c,v $$Revision: 4.0.1.6 $$Date: 91/11/11 16:38:45 $
Patch level: 19
Newsgroups: comp.lang.perl
From: mcook@fendahl.dev.cdx.mot.com (Michael Cook)
Subject: Re: Very tiny bug in printf? (perl 4.034)
Organization: Motorola Codex, Canton, Massachusetts
Date: Thu, 3 Sep 1992 16:02:10 GMT

hansk@aie.nl (Hans Kinwel) writes:

>I expected the following three lines to print out 08 two times.

>$val="8";
>printf ("%02s\n", $val);
>printf ("%02d\n", $val);

It probably depends on the underlying implementation of sprintf.

In _Standard C_ by Plauger and Brodie, they say "Following the percent
character (%), you can write zero or more flags: ... 0 -- to pad a conversion
with leading zeros after any sign or prefix, in the absence of any other
padding," which seems to be saying that you should get "08" for both.

Michael.
Newsgroups: comp.lang.perl
From: kent@manzi.unx.sas.com (Paul Kent)
Subject: nuther perl-idiom question..
Originator: kent@manzi.unx.sas.com
Date: Tue, 1 Sep 1992 22:55:35 GMT
Organization: SAS Institute Inc.



in kornshell, one can say:

  x=${foo:-default}

which assigns x the value of foo if foo is defined, and "default" otherwise...



in perl, one could:

  $x = defined($foo) ? $foo : "default";


but that gets ugly, specially when foo is an assoc array.

  $x = defined($foo{'this'}) ? $foo{'this'} : "default";





is there a better idiom. (other than loading the assoc array with
the defaults before one starts, which doesnt help if the "default"
varies from one spot to another in the code)

is there an idiom that references $foo once only?

best i could find is.. (and it doesnt handle the boundary of a "false" $foo{'this'}

  $x = $foo{'this'};
  $x = "default" unless $x;

the double assignment of x feels wrong, even if it is mostly elided.



this gets the same kornshell semantics, but the initial assigment of
$x seems rather buried.. ones eyes would tend to think that x didnt
get assigned by the statement unless...

  $x = "default" unless defined($x=$foo{'this'});


what say?
paul

-- 

Paul Kent (SQL r&d)                   " nothing ventured, nothing disclaimed "
kent@unx.sas.com         SAS Institute Inc, SAS Campus Dr, Cary NC 27513-2414.
From: joel@abigale.UUCP (Joel Rosi-Schwartz)
Newsgroups: comp.lang.perl
Subject: Re: more questions
Date: 29 Aug 92 09:52:59 GMT
Organization: Techne Research, Finchampstead, Berkshire (UK)

In article <1992Aug26.033044.9697@uoft02.utoledo.edu> steiner@jupiter.cse.utoledo.edu (jason "Think!" steiner) writes:
>here's something i've been wondering about:
>
>what's the best way to pipe output through a pager? (in this case more)
>i've tried just opening "|more", but that hangs on close, apparently
>because more is waiting for its parent to finish, and perl is waiting
>for more to exit. this also has the disadvantage that quitting more
>half way through the output also quits perl.
>
>i've got a feeling this is very simple, but don't know what it is...
>

I use code like this to page.

#### This is up top in my configuration section.

#
# Take your pick of pagers, cat is a last resort!
#
$more = "/usr/local/bin/less";
# $more = "/usr/bin/pg";
# $more = "/usr/bin/more";
# $more = "/usr/bin/cat";

#### I use code like this when I need the pager.

if ($i_need_to_page) {
	die "Pager \"$more\" not found. Please seen CONFIG section of $0\n"
		unless -x $more;

	open(MORE, "|$more");
	$oldhandle = select(MORE);
	$| = 1;
	print "DO YOUR STUFF HERE";
	close(MORE);
	wait;
	select($oldhandle);
}

Cheers,
Joel
-- 
     ==================================================================
     ||               T E C H N E   R E S E A R C H                  ||
     ||  ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  ||
     ||                     Joel Rosi-Schwartz                       ||
     ||   Hildorien House            +   Email: joel@abigale.UUCP    ||
     ||   12 Waverley Way            +    (pyrltd!abigale.UUCP!joel) ||
     ||   Finchampstead, Wokingham   +   Phone: +44 (734) 730.260    ||
     ||   Berkshire RG11 4YD (UK)    +   Fax:   +44 (734) 730.272    ||
     ==================================================================
From: ram@eiffel.com (Raphael Manfredi)
Newsgroups: comp.lang.perl
Subject: Re: Why is this foreach loop exiting early?
Date: 27 Aug 92 01:26:31 GMT
Organization: Interactive Software Engineering, Santa Barbara CA

Quoting nlane@well.sf.ca.us (Nathan D. Lane) from comp.lang.perl:
>chop(@farms = `cat $file`);

That is your problem. That is a "shell" behaviour. What you want is more:

@farms = split(/\n/, `cat $file`);

If the file is really big, it might be better (for memory usage) to write:

open(FARMS, $file) || die "Can't open $file: $!\n";
@farms = <FARMS>;	# Because $/ is "\n" and we are in array context
close FARMS;

>The program doesn't reach the second record, or at least doesn't process it.
>Needless to say, it doesn't find the INDEX line either (which is why I
>haven't gotten that part of the processing to function).  Any help would be
>appreciated, including suggestions on style.  I do want to learn!

So no wonder, it did not work, you were trying to process one big line,
and $* is 0 by default so you did not match anything I guess.

Your style is fine -- It looks like what I am writing :-)

Oh, BTW, I've just spot what might be a typo... Further down in your script,
you write:

	if ($farm =~ /INDEX/) {
		next until /\d+/;
		($Seq, $rest) = split(' ', $farm);
	}

Surely you meant 'unless' instead of 'until'.
-- 
Raphael Manfredi <ram@eiffel.com>
Interactive Software Engineering Inc.
270 Storke Road, Suite #7                      / Tel +1 (805) 685-1006 \
Goleta, California 93117, USA                  \ Fax +1 (805) 685-6869 /
From: peter@merlin.acadiau.ca (Peter Steele)
Newsgroups: comp.lang.perl
Subject: Simultaneous processes
Date: 26 Aug 92 14:20:21 GMT
Organization: Acadia University

How does one set up simultaneous processes in perl? For example,
how would I translate the following into perl:

    #!/bin/sh

    ls -la > d1 &
    ls -la > d2 &
    ls -la > d3 &
    wait
    cat d1 d2 d3 > d4

This is a pretty simplistic example, but illustrates what I want to
do in perl. The real program looks like this:

    #!/lbin/perl

    @dlist1 = split(/,/,$ARGV[0]);
    @dlist2 = split(/,/,$ARGV[1]);

    for ($i = 0; $i <= $#dlist1; $i++) {
        for ($j = -1; $j <= $#dlist2; $j++) {
            foreach $d (@dlist1[0..$i]) {
                spawn a process for $d and save its output somehow &
            }
            foreach $d (@dlist2[0..$j]) {
                spawn a process for $d and save its output somehow &
            }
            wait for all processes to complete and combine output;
        }
    }

This program takes two comma-separated lists and loops over the
values provided. If the program is called "fred", it would be
called as, for example,

    fred d1,d2 e1,e2,e3

The loops generate sets of values in the following pattern:

    d1
    d1,e1
    d1,e1,e2
    d1,e1,e2,e3
    d1,d2
    d1,d2,e1
    d1,d2,e1,e2
    d1,d2,e1,e2,e3

I want to spawn off simulataneous processes like this:

    do something with d1 &
    wait
    collect combined output

    do something with d1 &
    do something with e1 &
    wait
    collect combined output

and so on, with the last interation generating

    do something with d1 &
    do something with d2 &
    do something with e1 &
    do something with e2 &
    do something with e3 &
    wait
    collect combined output

Conceptually straightforward, but I'm not sure how to accomplish this
in perl. I'd also be happy with a pure Bourne shell solution. In fact,
that would probably be preferable. Does anyone know how to translate
the for loops above into shell?
--
Peter Steele        Unix Services Manager            peter.steele@acadiau.ca 
Acadia Univ., Wolfville, NS, Canada B0P 1X0  902-542-2201  Fax: 902-542-4364
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: Bad label: _EVAL_
Date: 4 Sep 92 17:38:00 GMT
Article-I.D.: netlabs.1992Sep4.173800.2894
Organization: NetLabs, Inc.

In article <1992Sep3.125634.18779@sbil.co.uk> jim@spitws117.sbil.co.uk writes:
: Oops.  There go another few hundreds or even thousands of dollars.

Gee, who wrote that stupid message anyway?  :-)

: After a little more experimentation I have discovered the error.  The
: script was written to be run by root and $oldfile is a file which is
: writable only by root (but readable by everyone).  When I tested the
: script as me with a file writable by me, and when I tested it as root
: with the original file, it worked fine.  Which leaves me with another
: question: why the cryptic bad label error instead of dying with the
: given error message?  What did I do wrong?

You probably returned out of an eval somewhere else, so the die command
still thought it was in an eval when it wasn't.

Larry
Newsgroups: comp.lang.perl
From: asherman@laser.fmrco.com (Aaron Sherman)
Subject: Re: how to get passwd
Reply-To: asherman@fmrco.COM
Organization: I-Kinetics, 19 Bishop-Allen Dr., Cambridge, MA
Distribution: usa
Date: Wed, 2 Sep 1992 16:07:20 GMT


>>>>> tony@hacgate.SCG.HAC.COM (Tony Reeves) said:

tony> I'm new to perl, so I'm sorry if this is a dumb question...

There are no such things as dumb questions.

tony> I want to read the last line of /etc/passwd and grep out the uid
tony> number.  I can't seem to do this. How can I do this easy? I
tony> tryed open, seek and split.  But it does not seem to work the
tony> way I read it in the man page. Can a perl expert help me?

That has to be the dumbest question I've ever heard in my life! ;-)

How about:

	$\="\n";
	open(F,'</etc/passwd') || die("Cannot open /etc/passwd: $!\n");
	$last = $_ while(<F>);
	print((split(/:/,$last))[2]+0);

or

	$\="\n";
	open(F,'</etc/passwd') || die("Cannot open /etc/passwd: $!\n");

	seek(F,-100,2);
      FIND:
	for($i=0;defined($c=getc(F)) && $c ne "\n" && $i < 100;$i++){1;}
	if ($c ne "\n") {seek(F,-200,1);goto FIND;}

	$last = $_ while(<F>);
	print((split(/:/,$last))[2]+0);



			-AJS

--
--------
Disclaimer: I am solely responsible for the content of this message.
The views expressed here may not be the views of I-Kinetics, Fidelity,
any of the Fidelity-owned corporations or my mother.
Newsgroups: comp.lang.perl
From: ken@eskimo.celestial.com (Ken Pizzini)
Subject: Re: comp.lang.perl.scripts (?)
Organization: -> ESKIMO NORTH (206) For-Ever <-
Date: Wed, 26 Aug 1992 09:54:18 GMT

merlyn@romulus.reed.edu (Randal L. Schwartz) writes:
> At most maybe a keyword or something in the subject line so that
> people can set their phasers on KILL if they choose not to see
> something.
> 
> Really... has skipping past source code been a problem for people
> here?

I think that at least a keyword, and perhaps a new group, is a good
idea so that automated archivers can readily spot "source".

		--Ken Pizzini
From: txl@teradata.com (Tuan Le)
Newsgroups: comp.lang.perl
Subject: Perl FAQ
Date: 31 Aug 92 17:19:18 GMT
Distribution: usa

Please help.  How do I get the FAQ for this line?  I don't have access to
direct FTP.  Is there a mail service where I can send for information?  If
you have a postcript file of the reference card, please post or email it to me.
Many thanks for your help.
-Tuan

Newsgroups: comp.lang.perl
From: allbery@NCoast.ORG (Brandon S. Allbery KF8NH)
Subject: Re: Line-by-line concatenation
Reply-To: allbery@ncoast.org (Brandon S. Allbery KF8NH)
Organization: North Coast Public Access *NIX, Cleveland, OH
Date: Wed, 26 Aug 1992 23:22:03 GMT
Followup-To: comp.lang.perl

As quoted from <1340@minya.UUCP> by jc@minya.UUCP (John Chambers):
+---------------
| In article <1992Aug5.194453.21473@mercury.unt.edu>, kenc@sol.acs.unt.edu (Ken Corey - Operator) writes:
| > mbgordy@athena.mit.edu (Michael B Gordy) writes:
| > >I have two data files which I need to concatenate horizontally.  ...
| > 
| > Um...isn't this the paste program?  Seems extravagant to write a perl
| > program to do this already.  paste file1 file2 *should* do it.
| 
| Consider the example from the manual page:
|    ls | paste - - - -
| This is supposed to produce four-column output.  It does put the names
| four  to a line, but in most directories, they will not be in columns.
| There seems to be no options that will produce columnar output.
+---------------

pr -m -t -w# file1 file2 ...

where # is the width (default 72).  May be System V only.

++Brandon
-- 
Brandon S. Allbery, KF8NH [44.70.4.88]: allbery@NCoast.ORG, bsa@telotech.com
Senior Programmer, Telotech, Inc. (if I may call myself that...)
Newsgroups: comp.lang.perl
From: ggr@koonda.acci.com.au (Greg Rose)
Subject: Re: help with if ( ! $a =~ /##/ ) PLEASE!!!
Organization: Australian Computing and Communications Institute
Date: Fri, 28 Aug 1992 02:44:06 GMT

In article <ericw.714945775@bach> ericw@bach.amd.com (Eric Wedaa) writes:
>I am having a h!@# of a time getting this code fragment to 
>work:
>
>if ( ! $a =~ /#/ ){
Well, if $a has anything in it, !$a is false and won't match.
Anyway, you can use the "doesn't match" version:

if ($a !~ /#/) {
--
Greg Rose                 Australian Computing and Communications Institute
ggr@acci.com.au                                              +61 3 282 2532
From: haynes@cats.ucsc.edu (Jim Haynes)
Newsgroups: comp.lang.perl
Subject: bug report
Date: 27 Aug 92 00:32:08 GMT
Organization: University of California; Santa Cruz
NNTP-Posting-Host: hobbes.ucsc.edu


disclaimer: I'm not yet a perl programmer, but a system manager running other
people's scripts.

On a Sun Sparc IPC, running SunOS 4.1.1
running perl 4.010 but it also happens with 4.019 and 4.035

I get a segmentation violation.  adb on the core dump file gives

# adb /usr/tmp/perl /sysdev/core
$c
core file = /sysdev/core -- program ``perl''
SIGSEGV 11: segmentation violation
_memcpy(?)
_realloc(0xc2c08,0xffffffff,0x0,0x19,0xb,0x3ff8) + 160
_str_grow(0x75a48,0xffffffff,0xfffffffd,0xffffffff,0x2018,0xc2c08) + b8
_str_gets(0x75a48,0xf77a1fd8,0xa,0x105408,0xfffffffd,0xc2c08) + 2c8
_cmd_exec(0x0,0x0,0x206,0x80,0x75a48,0x98388) + 1598
_cmd_exec(0x0,0x0,0x5000,0x0,0x747b8,0x93548) + 28e8
_do_subr(0x8b0c8,0x378b48,0x8eb88,0x1,0xffffffff,0x77c08) + 44c
_eval(0x8b0c8,0x77c04,0x1,0x59,0x3,0x8b108) + 5a9c
_cmd_exec(0x0,0x0,0x207,0x0,0x747b8,0x8b148) + 1de8
_cmd_exec(0x0,0x1,0x282,0xffffffff,0x747d8,0x8b488) + 251c
_cmd_exec(0x0,0x71,0x5207,0x80,0x873c8,0x8bac8) + 2958
_cmd_exec(0x0,0x0,0x1207,0x778ab,0x86a88,0x872c8) + 28e8
_main(0x0,0xf7fffd9c,0xf7fffdec,0x96c48,0xf7fffff9,0xa86c8) + 22b8

with perl compiled with debugging:
panic: realloc at /usr/local/change.pl line 235, <RCSFILE> line 308.

The context of the changelog.pl script is

            }
        }
        last if /^desc/;
    }

    while(<RCSFILE>) { # Skip description
        last if /^@+$|[^@]@$/;
    }

LINE 235>>>    while(<RCSFILE>) {
        chop;
        if (/^(\d)+\.(\d)+/) {
            if ($vers{$_}) {
                $v = $_;
                undef $rcs_text;
                $_ = <RCSFILE>; # get rid of "log"
                while(<RCSFILE>) {
                    last if /^@$/;
                    $rcs_text .= $_;
                }

and I don't know what RCSFILE contains at this point, because I don't
know the name of the file it was working on.  I could send the whole
script to anyone who cares to look at it.
-- 
haynes@cats.ucsc.edu
haynes@cats.bitnet

"Any clod can have the facts, but having opinions is an Art."
        Charles McCabe, San Francisco Chronicle
Newsgroups: comp.lang.perl
From: forrie@morwyn.uucp (Forrie Aldrich)
Subject: Cnews perl scripts
Organization: Vision Graphics
              Dover NH
              USA
Date: Tue, 25 Aug 1992 16:11:19 GMT

I've lost his address :( 

Would someone tell me who wrote the Cnews replacement scripts?  There
is yet another release of Cnews (the 'performance' release) and I do not
know if this has warranted further hacking at any perl scripts (I haven't
upgraded to the newest Cnews, yet).  

There was a problem with inews.pl stripping any and all '-' (dashes)
characters from messages, so I had to stop using it... etc etc. 

Thanks

-- 
	   -----------	      Forrest Aldrich	      -----------
	   -------     morwyn!forrie@unhtel.unh.edu	  -------
	   ----						     ----
	   --	     VISION GRAPHICS --	Dover, NH - USA	       --
	   ------------------------------------------------------
Newsgroups: comp.lang.perl
Subject: Re: Camel Book for 5.xxx hardback?
From: barr@pop.psu.edu (David Barr)
Date: Sun, 30 Aug 92 19:02:56 GMT
Distribution: Organization: Penn State Population Research Institute
Organization: Penn State Center for Academic Computing

In article <MERLYN.92Aug30092301@romulus.reed.edu> merlyn@ora.com (Randal L. Schwartz) writes:
>Of course, if your book wears out in 18 months, maybe that's the
>point; it's time to get a new book with the new information in it! :-)
>
>Maybe we should sell a subscription service? :-)

Hey, now there's an idea!  :-)

I got my camel book right before 4.0 came out and it's already starting
to show its age.  What's worse I think I've lent it out longer than I've
had it in my own posession!  :-/  I'm surprised I haven't lost the quick-
reference guide, though.

Is the quick-reference guide going to maintain it's "booklet" style
format?  (as opposed to the fold apart map-style format I've seen around)
Finding things is much easer when flipping pages, than trying to unfold
and refold those other kinds of guides.

--Dave
-- 
System Administrator, Population Research Institute    barr@pop.psu.edu
  "An analogy is like instant coffee: it can wake you up, but it's
  not the real thing"  -- Peter da Silva
Newsgroups: comp.lang.perl
From: mab@wdl39.wdl.loral.com (Mark A Biggar)
Subject: Re: easy question?: substrings
Organization: Loral Western Development Labs
Distribution: usa
Date: Thu, 27 Aug 1992 17:46:13 GMT

In article <BtM69K.54J@world.std.com> dsb@world.std.com (David Boyce) writes:
>In article <1992Aug26.222821.28341@news.eng.convex.com> tchrist@convex.COM (Tom Christiansen) writes:
>>From the keyboard of budnick@cbnewse.cb.att.com (Mary Jo Budnick):
>>:Hi!  I just started to use Perl and can't find the info in the
>>:Wall/Schwartz book very easily to solve my problem.  Help me out?
>>:All I want to do is to change a string in the format of either
>>:	0xffffff00 or ffffff00 into the format
>>:	of 255.255.255.0 
>>Try:
>>    $n = "ffffff00";
>>    print join(".", unpack(C4, pack(L, hex($n)))), "\n";
>>Add quotes around the format strings for old versions of perl.
>    Or what I find less obfuscated:
>$n = "0xffffff00";
>($junk, $f1, $f2, $f3, $f4) = $n=~/(0x|)(..)(..)(..)(..)/;
>printf "%d.%d.%d.%d\n", hex($f1), hex($f2), hex($f3), hex($f4);

It doesn't matter as much in this pattern but the use of | in () in very 
ineffecient, that pattern should be written /(0x)?(..)(..)(..)(..)/
In addition there is no reason to do the array assignment so the final version
is:

$n =~ /(0x)?(..)(..)(..)(..)/;
printf "%d.%d.%d.%d", hex($2), hex($3), hex($4), hex($5);

--
Perl's Maternal Uncle
Mark BIggar
mab@wdl1.wdl.loral.com

Newsgroups: comp.lang.perl
From: kelso@eng.umd.edu (John Kelso)
Subject: a daemon-checker daemon
Date: Tue, 25 Aug 92 20:23:16 GMT
Organization: University of Maryland, College Park


Greetings,

I'm about to start writing a daemon-checker daemon.  Basically I see this
as a program that will periodically check to see if each daemon from a list
of daemons is running, and if not, restart them.

I know that someone out there has done this before, so I thought that I'd
ask the group to send me their experience/code/flames with such a thing
before starting to do it on my own.  I'll summarize.

Thanks,

John
-- 
			John Kelso, Applications Manager
      University of Maryland College of Engineering, College Park MD 20742
		 kelso@eng.umd.edu -or- uunet!eng.umd.edu!kelso
--
Newsgroups: comp.lang.perl