HDTenEightyP/NetNews huggingface dataset:
From: dhami@cs.ubc.ca (Mandeep S Dhami)
Subject: Re: fork question
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
Date: Wed, 9 Sep 92 20:47:42 GMT

peter@merlin.acadiau.ca (Peter Steele) writes:
>
>$| = 1;
>print "Starting...\n";
>fork && &test1;
>fork && &test2;
>print "Done.\n";
>wait; wait;
>
>When I run this program, I'd expect the to wait calls to wait for the
>two child processes to complete. However, both of the calls return -1,
>and the parent exits before the child processes are done. Observe:

>merlin% testit
>Starting...
>test1
>Done.
>test2
>Done test1
>merlin% Done test2

>Why are the wait calls not waiting?
>

The problem, as I see it, is that you want fork || &test* NOT fork && &test*.
Because you want test to be executed by the child and the child sees
a value of fork == 0 (i.e && fails) but parent sees the pid and executes
test*.

Hope this variation on your solution helps:

print "Parent is $$\n";
fork || &test1;
fork || &test2;
print "wait 1 returns the pid - ", wait, "\n";
print "wait 2 returns the pid - ", wait, "\n";
print "Done $$\n";
exit 0;

sub test1 {sleep(2); print "Done test1 ($$)\n"; exit 0;}
sub test2 {sleep(4); print "Done test2 ($$)\n"; exit 0;}

which produces:
% testprog
Parent is 8836
Done test1 (8837)
wait 1 returns the pid - 8837
Done test2 (8838)
wait 2 returns the pid - 8838
Done 8836

What I think you want. To compare, check what I get if && is changed to ||.
which produces:
% testbroken
Parent is 8859
wait 1 returns the pid - -1
wait 2 returns the pid - -1
Done 8861
Done test1 (8859)
% Done test2 (8860)

NOT what you want!.

Hope this helps.
Mandeep (another grad looking for a real job!) Dhami.
__________________________________________________________________
"I'm very brave generally," he went on in a low voice:
"only to-day I happen to have a headache."
                                      -- Lewis Carroll
__________________________________________________________________
From: cjross@testament.bbn.com (Chris Ross)
Newsgroups: comp.lang.perl
Subject: What's the Right Way to undump perl on a SPARC?
Date: 8 Sep 1992 17:56:52 GMT
Organization: Bolt Beranek and Newman Inc., Cambridge MA
Distribution: world
Reply-To: cjross@bbn.com (Chris Ross)
NNTP-Posting-Host: bbn.com


When I use undump (from the Tex 3.0 distribution), the resulting
binary crashes when run.  When I try to build perl with unexec.c
from the Gnu Emacs distribution, ld complains that `start_of_data'
and `start_of_text' are undefined.

I could dig deeper on my own, but I'm out of time.
Can perl be undumped on a SPARC, or am I out of luck?


chris ross   <cjross@bbn.com>   BBN Advanced Simulations   (617) 873-3272
 WARNING: article may contain flammable material.  Do not expose to open
   flames.  In case of accidental ignition, douse keyboard with water.
From: cjross@bbn.com (Chris Ross)
Newsgroups: comp.lang.perl
Subject: gethostbyname() crash in pl 4.035 under SunOS 4.1.?
Date: 14 Sep 92 01:50:59 GMT
Reply-To: cjross@bbn.com (Chris Ross)
Organization: Bolt Beranek and Newman Inc., Cambridge MA
NNTP-Posting-Host: bbn.com


doio.c, lines 1738-1744 read as follows:

	    if (which == O_GHBYNAME) {
#ifdef h_addr
                str_nset(str, *hent->h_addr, hent->h_length);
#else
                str_nset(str, hent->h_addr, hent->h_length);
#endif

Sun's <netdb.h> defines h_addr as
#define h_addr	h_addr_list[0]	/* address, for backward compatiblity */

h_addr_list is dereferenced by both <netdb.h> and perl, which results
in a char being passed to str_nset.  I've no idea which is at fault.
The obvious quick fix works.


chris ross   <cjross@bbn.com>   BBN Advanced Simulations   (617) 873-3272
 WARNING: article may contain flammable material.  Do not expose to open
   flames.  In case of accidental ignition, douse keyboard with water.
Newsgroups: comp.lang.perl
From: bcutter@pdnis.paradyne.com (Brooks Cutter)
Subject: How to communicate both ways with a sub-process...
Organization: AT&T Paradyne, Largo Florida
Date: Tue, 8 Sep 92 01:45:46 GMT


I looked and looked and looked, but alas I couldn't find any info on
this in the O'Reilly Perl book...  (I'll find the info right after I 
finish this post, I'm sure...)


I'm looking for a way to open a two-way pipe with a sub-process...

I'd like to use this method to open a connection to telnet, ftp, etc.

(Yes, I'm aware of ftp.pl and chat2.pl -- However we are on the AT&T R&D
Internet and to get to the REAL internet we have to go through a custom
AT&T Proxy gateway... Rather than convert the constantly evolving library
routines from C, or re-linking perl with the libraries each time, I'd
like to use the telnet/ftp binaries that will be updated as often...
(Yes I've mastered the first great virtue of a programmer...)
I've also had problems with ftp.pl talking to a IBM (ack) Mainframe
running MVS and IBM's TCP/IP Ver 2 Rel 2 -- Talking to ftp rather
than directly to the daemon should solve this problem)

So Anyways... Is there a way to open a 2-way pipe or a package that
simulates this?  The only thing I could think of is creating a named
pipe and using that as the output/input for the program...

Yes I'm aware of the possibilities of deadlock... However the prompts
are well defined (for ftp at least) and I hope to avoid this...

(On a related note: I noticed that ftp attempts to read the password
from the terminal directly - instead of from stdin.  Can I fool ftp
with perl, or will I need to recompile it taking this out?)

Thanks...


-- 
Brooks Cutter    (I: bcutter@pdnis.paradyne.com)
                 (U: ...uunet!pdn!pdnis!bcutter)
Unix System Administrator, Information Services
        AT&T Paradyne, Largo Florida
Newsgroups: comp.lang.perl
From: victor@watson.ibm.com (Victor Miller)
Subject: perl dumps core on long regular expressions.
Date: Fri, 11 Sep 1992 13:42:04 GMT
Reply-To: victor@watson.ibm.com
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
Organization: IBM, T.J. Watson Research Center

I've tried the following script on perl 4.010 on an RS/6000, sun
sparcstation and IBM RT/PC.  If you call this script bug, then
bug n

where n is any number 30 or bigger dumps core, but an smaller value
terminates normally.  The local administrators haven't upgraded to
4.035 yet, so I can't test it on that.

#!/usr/bin/perl
$n = shift;
$n = 25 if $n eq "";
for $i (0..$n) {
    push(@files,sprintf("%3d",$i));
}
	 
$re = '^(' . join("|", @files) .  ')+$' ;

@a = ('a','AAA','AAAS');
foreach (@a) {
    $len{$_} = length if /$re/io;
}

--
		Victor S. Miller
		Bitnet: VICTOR at WATSON
		Internet: victor@watson.ibm.com
		IBM, TJ Watson Research Center
		"Great artists steal; lesser artists borrow" Igor Stravinsky
From: matthew@sunpix.East.Sun.COM (Matthew Stier - Sun NC Development Center)
Newsgroups: comp.lang.perl
Subject: Adding phincter into h2ph
Date: 15 Sep 1992 17:49:48 GMT
Organization: Sun Microsystems, Research Triangle Park, NC
Distribution: world
NNTP-Posting-Host: superdave.east.sun.com


Why scan thru the include files twice when once will do.

Most of the code in phincter appears to be grabbed directly from h2ph, so
I just merged the 'phincter' uniq code back into h2ph, and now h2ph will
try to grab all the include files it needs.

The first two segments of this patch implement phincter in h2ph.  The third
fixes a logic flaw in the handling of '#if' statements, where the subroutine
being called, is never declared.

c:
#if defined(ALWAYS);      /* Testing if ALWAYS declared */
#if (NEVER == 12);        /* NEVER is not declared      */

perl:
if defined(&ALWAYS);      # Testing if ALWAYS declared
if (&NEVER == 12)         # Perl tries to make a call to a subroutine 
                          # that does not exist.

fixed perl:
if defined(&ALWAYS);      # Testing if ALWAYS declared 
if (eval '&NEVER' == 12); # Run thru eval, to catch if NEVER is not declared


*** /depot/gnu/src/perl-4.035/h2ph	Fri Sep 11 23:28:27 1992
--- ./h2ph	Tue Sep 15 12:56:25 1992
***************
*** 19,24 ****
--- 19,28 ----
  @ARGV = ('-') unless @ARGV;
  
  foreach $file (@ARGV) {
+     $known{$file} = 1;
+ }
+ 
+ while ($file = shift(@ARGV)) {
      if ($file eq '-') {
  	open(IN, "-");
  	open(OUT, ">-");
***************
*** 93,99 ****
  		}
  	    }
  	    elsif (/^include\s+<(.*)>/) {
! 		($incl = $1) =~ s/\.h$/.ph/;
  		print OUT $t,"require '$incl';\n";
  	    }
  	    elsif (/^ifdef\s+(\w+)/) {
--- 97,109 ----
  		}
  	    }
  	    elsif (/^include\s+<(.*)>/) {
! 		$incl = $1;
! 		if (!defined($known{$incl}) && $file ne '-') {
! 		    # first encounter!  add to the list of arguments
! 		    push(@ARGV, $incl);
! 		    $known{$incl} = 1;
! 		}
! 		$incl =~ s/\.h$/.ph/;
  		print OUT $t,"require '$incl';\n";
  	    }
  	    elsif (/^ifdef\s+(\w+)/) {
***************
*** 193,199 ****
  		}
  	    }
  	    else {
! 		$new .= ' &' . $id;
  	    }
  	    next;
  	};
--- 203,209 ----
  		}
  	    }
  	    else {
! 		$new .= ($new =~ /defined\s*\($/ ? '&$id' : "eval '&$id'");
  	    }
  	    next;
  	};

-- 
Matthew Lee Stier                          |
Sun Microsystems ---  RTP, NC  27709-3447  |     "Wisconsin   Escapee"
Email: matthew.stier@East.Sun.COM          |
Phone: (919) 469-8300 fax: (919) 460-8355  | 
Newsgroups: comp.lang.perl
From: dhami@cs.ubc.ca (Mandeep S Dhami)
Subject: >> LVALUE =~ EXPR ? (performance question)
Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
Date: Fri, 4 Sep 92 23:06:08 GMT

pem@yarra-glen.aaii.oz.au (Paul E. Maisano) writes:
>	$_ = $some_meaningfully_named_variable;
>	(tr/abc/xyz/, s/foo/bar/, s/BAR/puppy/);

>But I might have been using $_ for something else.
>Probably this is best:
>	{ local($_) = ($some_meaningfully_named_variable);
>	  tr/abc/xyz/;
>	  s/foo/bar/;
>	  s/BAR/puppy/;
>	}

This got me thinking about the performance hit for an extra {} block.
So, I defined three functions as below:

sub one {
    $x='abcdeffoo';
    $x=~tr/abc/xyz/;
    $x=~s/foo/bar/o;
    $x=~s/def//o;
}

sub two {
    $x='abcdeffoo';
    { local($_)=$x; tr/abc/xyz/,s/foo/bar/o,s/def//o;}
}

sub three {
    $x='abcdeffoo';
    $tmp=$_; $_=$x;
    tr/abc/xyz/,s/foo/bar/o,s/def//o;
    $_=$tmp;
}

I expected &three to do better than &two (penalty for {}) and
I was not sure about &one (according to "The Camel Book" using
defaults does not (in general) improve perfomance, but some(?)
case are optimized). I got the following results and am a
little preplexed. Can someone explain the figures? (the script
was similar to the camel book timer.pl(?)).

$ time.pl
[Iter  ]cmd                                                   :user sys  u+s 
[1000  ]&one                                                  :0.05 0.08 0.13
[1000  ]&two                                                  :0.06 0    0.06
[1000  ]&three                                                :0.06 0    0.06
$ time.pl
[Iter  ]cmd                                                   :user sys  u+s 
[1000  ]&one                                                  :0.06 0.06 0.13
[1000  ]&two                                                  :0.06 0    0.06
[1000  ]&three                                                :0.06 0    0.06

$ time.pl
[Iter  ]cmd                                                   :user sys  u+s 
[10000 ]&one                                                  :0.63 0.06 0.70
[10000 ]&two                                                  :0.61 0.04 0.66
[10000 ]&three                                                :0.64 0    0.64
$ time.pl
[Iter  ]cmd                                                   :user sys  u+s 
[10000 ]&one                                                  :0.61 0.08 0.70
[10000 ]&two                                                  :0.66 0    0.66
[10000 ]&three                                                :0.65 0    0.65

Mandeep.
__________________________________________________________________
"I'm very brave generally," he went on in a low voice:
"only to-day I happen to have a headache."
                                      -- Lewis Carroll
__________________________________________________________________
From: ejk@ux2.cso.uiuc.edu (Ed Kubaitis - CCSO)
Newsgroups: comp.lang.perl
Subject: Re: perl dumps core on long regular expressions.
Date: 11 Sep 92 14:30:17 GMT
Organization: University of Illinois - Urbana

victor@watson.ibm.com (Victor Miller) writes:
  |I've tried the following script on perl 4.010 on an RS/6000, sun
  |sparcstation and IBM RT/PC.  If you call this script bug, then
  |bug n
  |
  |where n is any number 30 or bigger dumps core, but an smaller value
  |terminates normally.  The local administrators haven't upgraded to
  |4.035 yet, so I can't test it on that.
  |
  |#!/usr/bin/perl
  |$n = shift;
  |$n = 25 if $n eq "";
  |for $i (0..$n) {
  |    push(@files,sprintf("%3d",$i));
  |}
  |	 
  |$re = '^(' . join("|", @files) .  ')+$' ;
  |
  |@a = ('a','AAA','AAAS');
  |foreach (@a) {
  |    $len{$_} = length if /$re/io;
  |}

Had the same problem at 4.010. It was fixed at 4.019.

----------------------------------
Ed Kubaitis (ejk@ux2.cso.uiuc.edu)
Computing & Communications Services Office - University of Illinois, Urbana
From: rogers@fangorn.wr.tek.com (Roger Southwick)
Newsgroups: comp.lang.perl
Subject: "client" program (Camel book pg 338/339)
Date: 15 Sep 92 17:33:33 GMT
Organization: Tektronix, Inc.
X-Newsreader: Tin 1.1 PL5

Hi fellow perl hacks....

I'm fairly new to comp.lang.perl, and so if this subject has come up before, 
I apologize.... I've only been reading this newsgroup for 2 weeks.

I've been playing with the "client" program on pg 338/339 of the Camel
book and I've been unable to make it work.  It bails out with the error:

    Invalid argument at ./tst line 38.

Here's the snippet of code at that area:

    if(bind(S, $this)) {
	print "bind ok\n";
    }
    else {
	die $!;			# <=== line 38.
    }

My perl -v shows:

    $RCSfile: perl.c,v $$Revision: 4.0.1.7 $$Date: 92/06/08 14:50:39 $
    Patch level: 34

I'm running this on a Sun 4, SunOS 4.1.2.

I actually would like to know 2 things....

1) What is wrong with line 38 that 'die' can't print errno.
   I tried: die "$!";  	     # Same results.
	    die "hello $!";  # This one prints "hello" before the error message.

2) Why the program gets to this point at all (i.e. why did the bind() fail).

Any suggestions, pointers to ftp'able copies of Camel book perl sources
which work on 4.1.[12], $10,000,000 in small unmarked bills, etc. would
be appreciated.

Thanks in advance....
--
    -Roger      (Roger.S.Southwick@tek.com)
		UUCP:	...!uunet!tektronix!Roger.S.Southwick
From: pete@egh-qc.uucp (Pete Phillips)
Newsgroups: comp.lang.perl
Subject: Re: Camel Book for 5.xxx hardback?
Date: 7 Sep 92 12:31:32 GMT
Organization: Surgical Materials Testing Lab (SMTL)

>	sherman@unx.sas.com (Chris Sherman) writes:
>	>Actually, the Perl book on CD-ROM would be really handy!!!  I

>Todd> O'Reilly released a Hypercard version of "UNIX in a Nutshell"
>Todd> about four or five years ago. I used it quite a bit and found it
>Todd> useful and easy to use. .......

>I'd like to see them just release it as PostScript(tm) on a CDROM.
>That way it's machine independant, and I think most people can get at
>a PostScript(tm) previewer, or just print it out (they'd have to write
>up the license such that people were allowed to print it out for their
>own use, of course.

Well, it'd look nice on your screen, but the whole point of something
like the perl book on CD would be so that you could use grep, awk, or
some such utility (only joking here guys ;-) ) to search for
the types of things you are interested in. So you could find the
paragraph which describes the retab function by searching for
paragraphs with indent and tab.

I'd prefer raw text.  Then when you find something your interested in
you could cut it out and paste into your own code (I know that you can
get all the examples from the net, but it's not the same - browsing
the text on-line means you can see the code in context).

Pete
-- 
Pete Phillips, Surgical Materials Testing Lab, Bridgend, S. Wales.
UUCP   :  uknet!egh-qc!pete            DOMAIN :  pete@egh-qc.co.uk
-----------------------------------------------------------------
"SCIENCE: A way of finding things out and then making them work.  
Science explains what is happening around us the whole time.
So does RELIGION, but science is better because it comes up with 
more understand able excuses when its wrong. There is a lot more 
science than you think."
From: hhg1@gte.com (Hal German)
Newsgroups: comp.lang.perl
Subject: Re: Any guide to MS-DOS Perl?
Date: 11 Sep 92 11:32:38 GMT
Followup-To: comp.lang.perl
Distribution: usa
Organization: GTE Labs

In article <1992Sep9.204850.13493@uwm.edu>, stetzer@csd4.csd.uwm.edu (Frank
Stetzer) wrote:
> 
> I'm doing some work with the MS-DOS port of Perl.  Has anyone 
> compiled a list of things-to-beware-of in MS-DOS Perl?  For
> instance, "\n" generates the CR/LF sequence in MS-DOS Perl, 
> giving you 2 bytes where you were used to getting 1.
> 
> The "man" page that came with my MS-DOS Perl isn't DOS-
> specific.  My impression is that MS-DOS Perl is kind of 
> unexplored territory.
> ==========================================================================
> Frank Stetzer                                   stetzer@convex.csd.uwm.edu
> Statistical Software Coordinator                P.O. Box 413
> Computing Services Division                     Milwaukee, WI 53201
> University of Wisconsin - Milwaukee             (414)-229-4571

Depends whose MS-DOS Perl you are using. Len's and Tom's port does explain 
MS-DOS extensions. My book on Command Languages -- Command Language
Cookbook
by VNR (92) lists these extensions as well as those for the Amiga, Atari,
OS/2, Macintosh. I thank all the software authors who were kind enough to
allow me to use their material in the book.
From: tom@ssd.csd.harris.com (Tom Horsley)
Newsgroups: comp.lang.perl
Subject: Re: How to convice awk/sed users to use Perl ?
Date: 9 Sep 92 17:47:59 GMT
Organization: Harris Computer Systems Division

>>>>> Regarding How to convice awk/sed users to use Perl ?; swu@att.com (Chi-Sharn Wu) adds:
swu> Originator: news@cbnewsb.cb.att.com
swu> Nntp-Posting-Host: jolt.mt.att.com

swu> As a Perl beginner, I don't know how to answer the following question
swu> raised by my colleagues:
swu>    I use ksh/awk/sed very well, why bother to spend a lot of time to
swu>    learn Perl ?  What's the real advantages of perl over ksh/awk/sed ?

swu> I will appreciate any help.

swu> ---

swu> Chi-Sharn Wu
swu> swu@probe.att.com

The first time you have 'sed' or 'awk' tell you something like: "Expression
too complicated" or "too many files" or "array too big" you will figure out
why you need to use perl instead.

Typically, these problems crop up after you have had a sed or awk script in
dialy production use for six months to a year, then it suddenly fails
because you have overloaded some stupid internal limit, then you are totally
screwed and have to do a rewrite working around whatever limit you hit (if
you can figure out what it was). This is the most fun when the person
who originally wrote the script has left town :-).

If you use perl to start with, you don't run into nearly as many silly
limits (although I have heard rumors of stuff like regular expressions
bigger than 32K giving it heartburn). Mostly, if you have the available
memory, perl will not impose any other limits.
--
======================================================================
domain: tahorsley@csd.harris.com       USMail: Tom Horsley
  uucp: ...!uunet!hcx1!tahorsley               511 Kingbird Circle
                                               Delray Beach, FL  33444
+==== Censorship is the only form of Obscenity ======================+
|     (Wait, I forgot government tobacco subsidies...)               |
+====================================================================+
From: dwells@cognet.ucla.edu (David Wells)
Subject: Re: Camel Book for 5.xxx hardback?
Organization: UCLA Cognitive Science Program
Date: Tue, 8 Sep 1992 19:02:08 GMT

In article <1992Aug29.162151.1847@meiko.com> mike@meiko.com (Mike Stok) writes:
>If there's going to be a new Camel Book for the new Perl, will it ever
>be available as a hardback?  Of all the books on my shelf the Camel
>Book is the most heavily used (with the possible exception of
>Peopleware which is rarely on the shelf :-) and although it's only 18
>months old it's showing quite a few signs of wear and tear.  How many
>people out there would be interested in shelling out extra money for a
>more durable book?

Yeah - mine started losing pages after 2 weeks.  I called them, and
the new book will have a different binding.  Yea!


David

-- 
								David J Wells
"Cooking hotdogs with napalm"					w310/206-3960
	  - The Dead Milkmen			       dwells@cognet.ucla.edu
Newsgroups: comp.lang.perl
From: Tom Christiansen <tchrist@convex.COM>
Subject: Re: What's the difference between `command` and system('command')?
Originator: tchrist@pixel.convex.com
Date: Sat, 12 Sep 1992 18:25:31 GMT
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: Convex Computer Corporation, Colorado Springs, CO
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 peter@merlin.acadiau.ca (Peter Steele):
:>|> Where does error output go (i.e., stderr)? I have an application
:>|> where I want to capture error output, not stdout.
:
:>How about
:
:>	@lines = `cmd 2>&1`;
:
:>This runs cmd with stderr redirected to stdout.  It works with ksh - I
:>don't know about csh.q
:
:What's happens to normal stdout in this case? Is it lost? 

No, it's merged with stderr.

:Here's what I'm doing:
:  dump 0f - /somefs | compress | dd of=/dev/somedev

:I want to collect the stderr output of each of these commands. The
:only way I can think of doing this in perl is:
:
:  `dump 0f - /somefs 2>1.err | compress 2>2.err | dd of=/dev/somedev >3.err`
:
:and then open and extract the info I want from the three files that are
:created. Is this a reasonable way to do this in perl?

Pretty much.  While you could in theory play all the dup and fork 
games yourself and avoid temporaries that way, it's not fun.  

The shell is much more adroit at such games than perl.

But I would probably just run this in system(), not `cmd`.

--tom
-- 
    Tom Christiansen      tchrist@convex.com      convex!tchrist
"I sincerely hope that the future does not mean we must continually restrict
 ourselves to the tools that were available 10 years ago."
	Mark Bush in comp.unix.wizards <4235@inca.comlab.ox.ac.uk>
From: lwall@netlabs.com (Larry Wall)
Newsgroups: comp.lang.perl
Subject: Re: Removing duplicates from an array
Date: 13 Sep 92 04:50:30 GMT
Organization: NetLabs, Inc.

In article <18sod5INNgk7@swan.doc.ic.ac.uk> dds@doc.ic.ac.uk (Diomidis D Spinellis) writes:
: In article <lb27g1INNaef@jethro.Corp.Sun.COM> tmhoff@oogoody.Corp.Sun.COM writes:
: >Is there a cool way of removing duplicates from an array? I can think
: >of several methods, it could be an option on sort, but what is the
: >perl way?
: If you you know that no array element contains a \0 character, then the
: following will do the job:
: 
: 	%a = split("\0", join("\0\0", @a));
: 	@a = keys %a;

Or, if you don't care to worry about what your keys contain, use a slice:

	%a = ();
	@a{@a} = (1) x @a;
	@a = keys %a;

Of course, neither of those preserve order.  If you want to preserve order,
use the grep solution.

Larry