[6876] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 501 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 20 00:27:31 1997

Date: Mon, 19 May 97 21:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 19 May 1997     Volume: 8 Number: 501

Today's topics:
     Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "u <thpr@vnet.ibm.com>
     Re: Breaking on single line conditional blocks in the d (Jot Powers)
     Competent Perl Programmer Needed staff@zoron.net
     Re: Complex data Structures (Colin Kuskie)
     Re: convert functions in perl... (Mike Stok)
     Re: Getting File Size (Bill)
     Re: Getting File Size (Abigail)
     Help required - Perl 5 Installation under Windows NT 3. (Prasannas)
     Re: Help: How to Split a file at a Null Line??? (Tad McClellan)
     How could I do a wildcard search like real Search engin <wilkins@digitaldaze.com>
     How to output special characters with PERL (Dico Reyers)
     Re: if string in list ?? (Abigail)
     Re: if string in list ?? (Tad McClellan)
     Installation of Perl for NT 3.51 , IIS 1.0 (Prasannas)
     memory sharing between parent/child processes - Perl in <simonk@telebusiness.co.nz>
     Re: Need Help with Perl Script Implementation for e-Mai (Abigail)
     Perl 5.003 and setuid <blitz@axxis.com>
     Perl problems on HP 400 series <swamp@nortel.ca>
     Re: perlipc and multi-threading problem swarren@pdc.com
     print variable $abc which consist of '$' in it Query????
     Re: print variable $abc which consist of '$' in it (Nathan V. Patwardhan)
     running a script from a script liamtu@echonyc.com
     While loops starting with "1"? <markus@ibm.net>
     Re: While loops starting with "1"? (Tad McClellan)
     WinNT: getting File Last Modified data from outside cur (Loren Davidson)
     Re: Year 2000 compliance (Abigail)
     Re: Year 2000 compliance (Craig Berry)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 19 May 1997 17:23:33 -0400
From: Thomas Parker <thpr@vnet.ibm.com>
Subject: Re: > 2GB "file too large", AIX 4.2, perl 5.001, not "ulimit"
Message-Id: <3380C4D5.2781@vnet.ibm.com>

Sorry to disappoint anyone out there who dislikes AIX, 
but AIX 4.2 handles up to 64G files.  I agree with Kent's suggestion
(since edited out...) of trying to compile PERL on a 4.2 machine.

TP.

peter hakanson wrote:
> 
> Kent,
> if You have read the original post then you understand
> WHY aix4.2 (or any 32 bit machine has this limitation)
> 
> peter h
> --
> <peter.devnull@cyklop.volvo.se> (remove ".devnull" before use!)
> Peter Hakanson  VolvoData Dep 2580 phone +46 31 66 74 27

-- 
Thomas Parker
thpr@vnet.ibm.com  x6-4673 (TIE 446)


------------------------------

Date: 19 May 1997 21:58:26 GMT
From: jotmar97@tmp.medtronic.com (Jot Powers)
Subject: Re: Breaking on single line conditional blocks in the debugger
Message-Id: <5lqie2$lb7$1@gazette.corp.medtronic.com>

In article <5lqfak$598$2@mathserv.mps.ohio-state.edu>, ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
>[A complimentary Cc of this posting was sent to Jot Powers
><jot.mar97@tmp.medtronic.com>],
>who wrote in article <5lqask$isf$1@gazette.corp.medtronic.com>:

[*snip my explanation plus Ilya's commentary on something looking wrong*]

I apologize.  I lied.  :)

My program that I posted actually had 2 lines that weren't breakable that
were:

#!/usr/local/bin/perl

(a blank line)

So, if I do what we did before I get what you get.  I apologize if
that was misleading, I was (mistakenly it would appear) trying to
eliminate unnecessary bandwidth eating.

Here is me not being a schmuck:

node127% perl -wd bug.pl
Stack dump during die enabled outside of evals.
 
Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.
 
Enter h or `h h' for help.
 
main::(bug.pl:1):       $bob = 1;
  DB<1> l
1==>    $bob = 1;
2:      if ( $bob == 0) {print "Bob: $bob\n";}
3:      if ($bob == 0) {
4:              print "Bob: $bob\n";
5:      }
6:      if ($bob == 1) { print "Bob: $bob\n";}
  DB<1> 

>the debugger will pick up one of them.  As you can guess now, it picks
>the later one, thus one inside the (false) conditional.

Ok, it makes sense to me that there are now 2 break points on a line
(one for the conditional, one for the print).

However, I would assume that the expected behavior would be for it
to use the first not the second.

Am I the only one that expects this?  (Ok, wants it...others would expect
it since they would bother to scan the source to find out.  :)

A related question would be is it possible to change this behavior?

-Jot

p.s.:  My commentary on the from address munging.  I munged mine, but the
email will still get through, I just filter it.  This seems to me to
be more reasonable than bouncing all mail.  Guess mailagent/procmail
is too easy.  :)

-- 
Jot Powers  jot.mar97@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




------------------------------

Date: Mon, 19 May 1997 19:51:39 -0600
From: staff@zoron.net
Subject: Competent Perl Programmer Needed
Message-Id: <864089070.16009@dejanews.com>

Competent perl programmer needed for full time employment with fast
growing Internet based company. Salary DOE. contact staff@zoron.net for
additional information, or to submit resumes. HTML, C and UNIX experience
a big plus!

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


------------------------------

Date: 19 May 1997 09:03:59 -0700
From: colink@latticesemi.com (Colin Kuskie)
Subject: Re: Complex data Structures
Message-Id: <5lptlf$l0r@defiant.latticesemi.com>

In article <5l7v0d$fis@news2.widomaker.com>, SS <sscruggs@cucinc.com> wrote:
>I am trying to use an array of arrays, and I cannot seem to pull out the 
>size of the second array.  
>Code would look something like this:
>for $towhat ( 0 .. 15 ) {
>   for $tohuh (0 ,, 12) {
                  ^^
This should be `..'  Probably just a mistype, right?

>      $my_array[$towhat][$tohuh] = "Row: $towhat, Column: $tohuh\n";
>   }
>}
>for $counter ( 0 .. (scalar @my_array)) { #This one works;
>   for $index (0 .. (scalar @my_array[$counter])) { #But when you try
                             ^^^^^^^^^^^^^^^^^^^
Try

scalar @{ $my_array[$counter] }

instead.

Hope this helps,
Colin


------------------------------

Date: 19 May 1997 21:35:53 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: convert functions in perl...
Message-Id: <5lqh3p$qtg@news-central.tiac.net>

In article <01bc6497$7d9e58e0$0c83f6c8@afxtd-02>,
Sergio Stateri Jr <serginho@usa.net> wrote:
>Hi! How can I do to convert a decimal value to a hex value in Perl ? I
>thought that hex function did it, but it converts the hex value to a
>decimal value...It's the oposite of the other languages :))

ypo can use sprintf (to "print" to a string) or printf which prints to a
filehandle.  both use the same format specifiers which are described in
the perlfunc man page, but you might say:

  $num = 123;
  printf "%d is %x\n", $num, $num;

where the % signe introduce format specifiers and the arguments after the
format string are used as format specifiers are discovered running left to
right.

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


------------------------------

Date: 19 May 1997 21:24:24 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: Getting File Size
Message-Id: <slrn5o1h88.p2q.bill@granite.sover.net>

In article <864072575.454@dejanews.com>, cwyatt@cris.com wrote:
>The UNIX command is 'du + filename'.  However, I'm not one to want to make
>a lot of system specific calls.  Is there a manner in Perl to echo back a
>given file's size?
>
>Thanks!
>
>Chuck Wyatt

   Check out the stat() function.  It returns an array of all kinds of 
info on a given file, one of which is file size.  Try something like

  $size = (stat("filename"))[7];  # Grab 8th element of list returned by stat

						Bill
-- 
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.


------------------------------

Date: Mon, 19 May 1997 22:17:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Getting File Size
Message-Id: <EAG8Kz.799@nonexistent.com>

On Mon, 19 May 1997 15:21:39 -0600, cwyatt@cris.com wrote in
comp.lang.perl.misc URL: news:864072575.454@dejanews.com:
++ The UNIX command is 'du + filename'.  However, I'm not one to want to make
++ a lot of system specific calls.  Is there a manner in Perl to echo back a
++ given file's size?


perl -we '$_ = shift; printf "%6d %s\n", -M, $_' file


That doesn't simulate du's behaviour for directories though.



Abigail


------------------------------

Date: 19 May 1997 21:22:37 GMT
From: prasannas@aol.com (Prasannas)
Subject: Help required - Perl 5 Installation under Windows NT 3.51
Message-Id: <19970520012200.VAA21185@ladder02.news.aol.com>

I downloaded perl5 from the web. I seem to have some problems in
installating it. I'm not sure whether its installed properly. when i tried
to run a test.pl script the Internet explorer recognised it as a text file
and opens it as a text file instead of running the script. I did map the
 .pl file extension under Internet Explorer options.

What else should i do to install and configure perl properly. ?

THe following is the configuration I have.
MS-windows NT 3.51 server, service pack 4
Internet Information Server 1.0
Perl 5. for WIndows NT.

thanks
prasanna
email : prasannavs@aol.com


------------------------------

Date: Mon, 19 May 1997 19:08:21 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help: How to Split a file at a Null Line???
Message-Id: <l1qql5.0g4.ln@localhost>

Tung-chiang Yang (tcyang@netcom.com) wrote:
: This seems to be a better idea.  However, if there are more than
: one empty line in the input file, say

: ---
: lines 1-13

: lines 14-35

: lines 36-87

: lines 88-90
: ---

: Will your program leave lines 1-13 in 'file1' and lines 88-90 in
: 'file2' and skip over lines 14-35 and 36-87?


Yep. But it doesn't really "skip" them, they just get overwritten.



: (Of course for the original question, it is O.K. if we know for sure
: there is only one empty line in the file)


I write 'em to the specification given ;-)

(ie. bad spec yields bad solution...)



: ===================================================
: Tad McClellan (tadmc@flash.net) wrote:

: : #! /usr/bin/perl -w

: : open(OUT, ">file1") || die "could not open file1  $!";

: : while (<>) {
: :    if (/^$/) {  # found an empty line
: :       # open() below does an implicit close(OUT) first
: :       open(OUT, ">file2") || die "could not open file2  $!";
: :       next;
: :    }
: :    print OUT;
: : }

: : close(OUT);


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: 20 May 1997 00:59:05 GMT
From: "Brandon Wilkins" <wilkins@digitaldaze.com>
Subject: How could I do a wildcard search like real Search engines do?
Message-Id: <5lqt0p$a8f$1@news10.gte.net>


  I am writing a database for a client and I need some advise on searching
a parts list.  What is happening is that the parts are listed as
(Example:)

1N4001-1N4007
2W005G-2W10G

Now how could I make it so if someone enters 1N4003 it will match the first
example?  Is there a way to use the  =~ /$keyword/i with a wildcard (ie: *
)???


_ANY_ Would be appreciated Greatly,

Brandon Wilkins
wilkins@digitaldaze.com




------------------------------

Date: Tue, 20 May 1997 00:46:29 GMT
From: dico@peionline.com (Dico Reyers)
Subject: How to output special characters with PERL
Message-Id: <3380f3e7.30106048@news1.pei.sympatico.ca>

Hello.

I am writing a script in PERL that outputs special characters like  "
and   '  to the HTML page.  For example...


print "<a href="./blabla.html">\n";
                      ^                   ^

These little do-hickeys cause a problem?  How do I fix this?

Please email responses to 

dico@peionline.com

Thanks,

Dico


------------------------------

Date: Tue, 20 May 1997 00:03:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: if string in list ??
Message-Id: <EAGDHK.EpM@nonexistent.com>

On 19 May 1997 17:49:22 -0400, Michael Mellinger wrote in
comp.lang.perl.misc URL: news:v5ck9kvqgil.fsf@panix2.panix.com:
++ 
++ Is there a simple way to determine if a value is in a list?  I figure
++ that this should be a one liner.
++ 
++ @a=('one','two','three');
++ 
++ while(<>) { 
++ 
++   ($f1,$f2,$f3)=split(',', $_);
++   if ( $f2 in @a ) {  # How do I do this?
++      print "Hello world\n";
++   }


I think that was answered here only a few days ago.

Grep for grep in your man page.


Abigail


------------------------------

Date: Mon, 19 May 1997 19:03:15 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: if string in list ??
Message-Id: <3opql5.0g4.ln@localhost>

Michael Mellinger (melling@panix2.panix.com) wrote:

: Is there a simple way to determine if a value is in a list?  I figure
: that this should be a one liner.

: @a=('one','two','three');

: while(<>) { 

:   ($f1,$f2,$f3)=split(',', $_);
:   if ( $f2 in @a ) {  # How do I do this?
:      print "Hello world\n";
:   }

: }


from the Perl FAQ part 4:


--------------------------
=head2 How can I tell whether an array contains a certain element?

There are several ways to approach this.  If you are going to make
this query many times and the values are arbitrary strings, the
fastest way is probably to invert the original array and keep an
associative array lying about whose keys are the first array's values.

    @blues = qw/azure cerulean teal turquoise lapis-lazuli/;
    undef %is_blue;
    for (@blues) { $is_blue{$_} = 1 }

Now you can check whether $is_blue{$some_color}.  It might have been a
good idea to keep the blues all in a hash in the first place.

If the values are all small integers, you could use a simple indexed
array.  This kind of an array will take up less space:

    @primes = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31);
    undef @is_tiny_prime;
    for (@primes) { $is_tiny_prime[$_] = 1; }

Now you check whether $is_tiny_prime[$some_number].

If the values in question are integers instead of strings, you can save
quite a lot of space by using bit strings instead:

    @articles = ( 1..10, 150..2000, 2017 );
    undef $read;
    grep (vec($read,$_,1) = 1, @articles);

Now check whether C<vec($read,$n,1)> is true for some C<$n>.

Please do not use

    $is_there = grep $_ eq $whatever, @array;

or worse yet

    $is_there = grep /$whatever/, @array;

These are slow (checks every element even if the first matches),
inefficient (same reason), and potentially buggy (what if there are
regexp characters in $whatever?).
--------------------------


You must have missed that when you checked the Perl FAQ before
posting to the Perl newsgroup.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: 19 May 1997 21:21:08 GMT
From: prasannas@aol.com (Prasannas)
Subject: Installation of Perl for NT 3.51 , IIS 1.0
Message-Id: <19970520012100.VAA21031@ladder02.news.aol.com>

I downloaded perl5 from the web. I seem to have some problems in
installating it. I'm not sure whether its installed properly. when i tried
to run a test.pl script the Internet explorer recognised it as a text file
and opens it as a text file instead of running the script. I did map the
 .pl file extension under Internet Explorer options.

What else should i do to install and configure perl properly. ?

THe following is the configuration I have.
MS-windows NT 3.51 server, service pack 4
Internet Information Server 1.0
Perl 5. for WIndows NT.

thanks
prasanna
email : prasannavs@aol.com


------------------------------

Date: 19 May 1997 21:34:05 GMT
From: "Simon Kitching" <simonk@telebusiness.co.nz>
Subject: memory sharing between parent/child processes - Perl internals knowledge needed
Message-Id: <01bc649c$fdf3a450$cbe824ca@simonk>

This is probably a question which can only be answered by one of the Perl
porters, but I don't wish to pollute that group. Any help here will be
*greatly* appreciated.

I have a Perl program which initialises lots of large data structures on
startup.
The process then forks a child to handle client application requests (ie
standard client-server stuff) as required. I need to handle up to 500
client processes simultaneously, ie 500 copies of the program running plus
the original parent process.

It all works fine, but I am concerned by the lack of memory sharing between
the parent and child processes. The system was carefully designed so that
lots of "read-only" data structures were initialised in the parent process
- these pages should be shared by all the child processes. IE when the
child process is created, all these pages are marked "copy-on-write", but
the child never writes to these "read-only" pages, so the data page exists
only once no matter how many child processes exist.

Unfortunately, this data sharing does not seem to be happening. My
questions are:

1) Does the garbage collector write to each page, triggering the
"copy-on-write"?

2) Does Perl update the parse tree of the Perl files it loads? ie is there
"administration" information which gets updated in the data structures it
builds to hold its "executable code".

3) Is there any way of managing the way Perl allocates memory for its
variables? It would make sense to allocate all the scalars, lists and
hashes which are "read-only" from the child processes' point of view in one
set of memory pages, and all other variables in another set of memory
pages. I suspect that there may be small "holes" in between the "read-only"
data structures caused by temporary variables used by the initialisation
routines, and that the child instances are using these holes for their
temporary variables, thus dirtying many of the pages. Ideally, I would
"malloc" a (eg) 10 MB block and do all memory allocation from this block
during initialisation, then switch back to normal memory allocation. Child
processes would then never mix their variables in with the initialised
"read-only" variables.

I am using an RS6000 running AIX , and Perl 5.003_01

Any information would be appreciated. Thanks in advance....

------------------------
Simon Kitching
simonk@telebusiness.co.nz


------------------------------

Date: Tue, 20 May 1997 01:41:55 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Need Help with Perl Script Implementation for e-Mail .HTM Form
Message-Id: <EAGI1v.Ms6@nonexistent.com>

On Mon, 19 May 1997 16:27:41 -0700, Webmaster(SB) wrote in
comp.lang.perl.misc URL: news:3380E1ED.3BA@icsi.net:
++ I am a rookie who just created our company Web page.
++ In order to focus received e-mail (instead of "mailto:")
++ I downloaded a Perl Script "FORMMAIL.PL" from Matt's Script
++  Archive at "http://www.worldwidemart.com/scripts/".
++ I created an .HTM file containing a FORM which POSTs 
++ to FORMMAIL.PL.  I followed all MSA's documentation 
++ instructions, then FTP'd the .HTM file and the 
++ Perl Script (renamed to FORMMAIL.CGI) to my ISP's server.
++ 
++ When I complete the form it seems to work fine.  However, 
++ when I click the SUBMIT button, I get a response as follows:
++ 
++ ---------------------------------------------------------------------
++   Server Error
++ 
++   The server encountered an internal error or misconfiguration and 
++   was unable to complete your request.
++ 
++   Please contact the server administrator, webmaster@kwire.com and 
++   inform them of the time the error occurred, and anything you might 
++   have done that may have caused the error. 
++ ---------------------------------------------------------------------
++ 
++ I'm sure there's a problem with the .CGI script, but I am not a Unix or
++ Perl expert and need some help.  Can somebody help?
++ My ISP is actually or faking ignorance of PERL.
++ 

So, what does the errorlog say? (99.5% of the time you find the answer there).
What happens when you run it from the command line?
What did the people in comp.infosystems.www.authoring.cgi say?
Did you read "The Idiot's Guide to Solving Perl CGI Problems"
    [http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html]?




Abigail


------------------------------

Date: Mon, 19 May 1997 16:46:46 -0600
From: "Q. Wade Billings" <blitz@axxis.com>
Subject: Perl 5.003 and setuid
Message-Id: <3380D856.609C@axxis.com>

Help...

I am trying to run a perl script that will automated adding users to my
ISP. I was using 5.002 just fine, but now that I have installed 5.003,
the script refuses to run correctly. 

What is happening is the script has the permissions of rwsr-xr-x and is
owned by root:wheel. The script is suppose to open the master.passwd
file which has the permissions of rw------- and is owned by root:wheel.
What I am getting is a fatal error that the script can not open the
master.password file. I changed the permissions of /usr/bin/perl to
include the setuid bit, and changed the owner to root:wheel, and it runs
just fine. I do not however like having the binary run as root with the
setuid bit. 

Can someone offer a fix to this I have recompiled perl and set the
kernel support for secure setuid to 'yes'. If I am missing something
please let me know.

Thanks,

Q. Wade Billings
AXXIS Internet Services
Network Systems Administrator


------------------------------

Date: Mon, 19 May 1997 17:14:21 -0400
From: Steve Swamp <swamp@nortel.ca>
Subject: Perl problems on HP 400 series
Message-Id: <3380C2AD.41C67EA6@nortel.ca>

I've been trying to build perl for the HP 68K platform (don't laugh).
I can get it to build and test fine, but when I use the #! invocation
at the top of the script, I get the message of

No job control in this shell

If I type "perl <scriptname>", everything works fine.


Any guesses? Any help is appreciated.


-- 
steve swamp                       Northern Telecom
email: swamp@nortel.ca            Research Triangle Park, NC


------------------------------

Date: 19 May 1997 14:15:31 -0700
From: swarren@pdc.com
Subject: Re: perlipc and multi-threading problem
Message-Id: <5lqftj$h5q@drn.zippo.com>

In article <338093C1.7DC1@corp.airmedia.com>, Paul says...
                        ...
>sub reaper
>{
>    # note: next two lines in reverse order from Blue Camel!
>    $waitedpid = wait;
>    $SIG{CHLD} = \&reaper;
>    # print STDERR "DEBUG: reaped process $waitedpid with exit $?\n";
>}
>
>You'll have to tweak it in order to get the WNOHANG behavior ... or you
>can count on it being called once per death-of-child, avoiding both the
>need for a loop and for waiting-without-hanging.
 
Thanks, Paul, this fixed the waitpid() hang problem (that is where it was
hanging).

Unfortunately even when the reaper signal handler is short enough, perl
still seems to lose track of some of the SIGCHLD signals if they come in
too fast.  Here is my latest incarnation, which behaves mostly
OK (BTW this code works fine as long as the child processes exit
well-spaced from each other in time), except that it misses some of the
child processes because, in this test case, they all exit at close to the
same time (which we can't predict will not happen in real life):

#!/usr/local/bin/perl

my $waitedpid=0;
my $waitstat=0;

use POSIX ":sys_wait_h";
sub REAPER {
    $waitedpid = waitpid(-1,WNOHANG);
    $waitstat=$?;
    $SIG{CHLD} = \&REAPER;  # still loathe sysV
}
$SIG{CHLD} = \&REAPER;

sub spawn {
    my $pid;
    if (!defined($pid = fork)) {
        printf(STDERR "cannot fork: $!\n");
        return;
    } elsif ($pid) {
        printf(STDERR "begat $pid\n");
        push(pidList,$pid);             # Using this for kill list
        $Kid_Status{$pid}=-1;           # Seed the status with -1
        return; # I'm the parent
    }
 
    # else I'm the child -- go spawn
    sleep(1);   # Don't space the child exits this time
                                         
    printf(STDERR "Child #%s exiting...\n",$Thread);
    exit($Thread);
}
 
sub PRINTSTAT {
    my $pid;
    $Counter=0;
    foreach $pid (keys(Kid_Status)) {
        printf(STDERR "Kid_Status{%s}=%s; 
Kill(0)=%s.\n",$pid,$Kid_Status{$pid},kill(0,$pid));  
	$Counter++ if $Kid_Status{$pid}<0;
    }
    printf(STDERR "\n");
    return($Counter);         # Using this to count how many unsignaled
}                             # child processes remain
 
for ( $Thread = 0;$Thread <= 10;$Thread++)
{
    printf(STDERR "Forking thread #%s: ",$Thread);    
    &spawn;
}
 
printf(STDERR "\n");
 
while(&PRINTSTAT){
    sleep;
    $Kid_Status{$waitedpid}=$waitstat >> 8;
}

Here is the output from this program.  As you can see, I am forking
11 child processes, all of which exit at close to the same time.  This
appears to overload perl's capacity to handle them (I'm speculating),
because at the end, it hangs in the while-loop waiting for those last
few signals to come in, which they never do:

29) pdctx1:/home/swarren> !!
 ./fork4.pl | & tee fork.log
Forking thread #0: begat 17711
Forking thread #1: begat 17712
Forking thread #2: begat 17713
Forking thread #3: begat 17714
Forking thread #4: begat 17715
Forking thread #5: begat 17716
Forking thread #6: begat 17717
Forking thread #7: begat 17718
Forking thread #8: begat 17719
Forking thread #9: begat 17720
Forking thread #10: begat 17721
 
Kid_Status{17720}=-1; Kill(0)=1.
Kid_Status{17711}=-1; Kill(0)=1.
Kid_Status{17721}=-1; Kill(0)=1.
Kid_Status{17712}=-1; Kill(0)=1.
Kid_Status{17713}=-1; Kill(0)=1.
Kid_Status{17714}=-1; Kill(0)=1.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Child #0 exiting...
Child #1 exiting...
Child #2 exiting...
Kid_Status{17720}=-1; Kill(0)=1.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=-1; Kill(0)=1.
Kid_Status{17712}=-1; Kill(0)=1.
Kid_Status{17713}=-1; Kill(0)=1.
Kid_Status{17714}=-1; Kill(0)=1.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Kid_Status{17720}=-1; Kill(0)=1.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=-1; Kill(0)=1.
Kid_Status{17712}=1; Kill(0)=0.
Kid_Status{17713}=-1; Kill(0)=1.
Kid_Status{17714}=-1; Kill(0)=1.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Kid_Status{17720}=-1; Kill(0)=1.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=-1; Kill(0)=1.
Kid_Status{17712}=1; Kill(0)=0.
Kid_Status{17713}=2; Kill(0)=0.
Kid_Status{17714}=-1; Kill(0)=1.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Child #3 exiting...
Child #4 exiting...
Child #5 exiting...
Child #6 exiting...
Child #7 exiting...
Child #8 exiting...
Child #9 exiting...
Child #10 exiting...
Kid_Status{17720}=-1; Kill(0)=1.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=-1; Kill(0)=1.
Kid_Status{17712}=1; Kill(0)=0.
Kid_Status{17713}=2; Kill(0)=0.
Kid_Status{17714}=3; Kill(0)=0.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Kid_Status{17720}=-1; Kill(0)=1.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=10; Kill(0)=0.
Kid_Status{17712}=1; Kill(0)=0.
Kid_Status{17713}=2; Kill(0)=0.
Kid_Status{17714}=3; Kill(0)=0.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Kid_Status{17720}=9; Kill(0)=0.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=10; Kill(0)=0.
Kid_Status{17712}=1; Kill(0)=0.
Kid_Status{17713}=2; Kill(0)=0.
Kid_Status{17714}=3; Kill(0)=0.
Kid_Status{17715}=-1; Kill(0)=1.
Kid_Status{17716}=-1; Kill(0)=1.
Kid_Status{17717}=-1; Kill(0)=1.
Kid_Status{17718}=-1; Kill(0)=1.
Kid_Status{17719}=-1; Kill(0)=1.
 
Kid_Status{17720}=9; Kill(0)=0.
Kid_Status{17711}=0; Kill(0)=0.
Kid_Status{17721}=10; Kill(0)=0.
Kid_Status{17712}=1; Kill(0)=0.
Kid_Status{17713}=2; Kill(0)=0.
Kid_Status{17714}=3; Kill(0)=0.
Kid_Status{17715}=-1; Kill(0)=0.
Kid_Status{17716}=-1; Kill(0)=0.
Kid_Status{17717}=-1; Kill(0)=0.
Kid_Status{17718}=7; Kill(0)=0.
Kid_Status{17719}=-1; Kill(0)=0.

(wait here forever...)

Steve Warren                           E-mail: swarren@pdc.com     _.  
Central Regional SE Manager            Phone: 972-446-2644       ._||__
PDC Services                           Fax: 972-245-9320          v\ *|
1445 MacArthur Dr, Suite 116           Pager: 214-249-8651          V  
Carrollton, TX  75007                  http://www.pdc.com


------------------------------

Date: 19 May 1997 23:59:43 GMT
From: Query????
Subject: print variable $abc which consist of '$' in it
Message-Id: <5lqphf$hhi@triton.np.ac.sg>

Hi,

     How do I print a variable($abc) which consist of '$' in it.
     The variable is read from the lines of a file.

     while ( $abc = <inputfile> )
     {
        print "$abc";
     }

     Any pointers would be appreciated.                          




------------------------------

Date: 20 May 1997 00:46:37 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: print variable $abc which consist of '$' in it
Message-Id: <5lqs9d$e27@fridge-nf0.shore.net>

Query???? wrote:

:      How do I print a variable($abc) which consist of '$' in it.
:      The variable is read from the lines of a file.

Ok.  This is your third posting which is basically the same as the other
two.  You provide no details RE: what you're doing now - how can we know 
why it isn't working if you don't show us some code, dang-it?

Please post some code so we have some idea why your program isn't working.

Thank goodness you didn't want a CC as your e-mail address is busted.

--
Nathan V. Patwardhan
nvp@shore.net



------------------------------

Date: Mon, 19 May 1997 16:42:53 -0600
From: liamtu@echonyc.com
Subject: running a script from a script
Message-Id: <864077683.5297@dejanews.com>

I need to get the result of a perl script for use in a perl script... when
I open the file in perl I just get the script text. I know there must be a
simple answer.

Thanks

-Liam

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


------------------------------

Date: Mon, 19 May 1997 21:43:56 +0200
From: Markus Schlegel <markus@ibm.net>
Subject: While loops starting with "1"?
Message-Id: <3380AD7C.249BD411@ibm.net>

Hello everyone,

I recently saw a strange construct, looking like this:

# put commas in the right places in an integer

1 while s/ (\d) (\d\d\d) (!?\d)/($1,$2);

(From "programming Perl", O'Reilly)


My question here is: Is the "1" in this line used as a
boolean, and if so, why is this legal, since this doesn't
look conform to any "while" statement I have used so far.

(Another case of cryptic shorthand here, perhaps).

Any help would be appreciated, also on what code around this
to read from and write back the substitution to a file 
might look like.

Best thanks,
Markus Schlegel

--
Markus Schlegel
markus@ibm.net



------------------------------

Date: Mon, 19 May 1997 19:32:40 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: While loops starting with "1"?
Message-Id: <8frql5.9l4.ln@localhost>

Markus Schlegel (markus@ibm.net) wrote:
: Hello everyone,

: I recently saw a strange construct, looking like this:

: # put commas in the right places in an integer

: 1 while s/ (\d) (\d\d\d) (!?\d)/($1,$2);

: (From "programming Perl", O'Reilly)


: My question here is: Is the "1" in this line used as a
: boolean, 


Nope. It is basically just a NOP (NO Operation) 'cause the conditional
itself (s///) does all the work.


: and if so, why is this legal, since this doesn't
: look conform to any "while" statement I have used so far.


while (s/ (\d) (\d\d\d) (!?\d)/($1,$2))  {}
                                         ^^
                                         ^^
does the same thing (I preserved your typo, the replacement part is
missing a closing slash...)



: (Another case of cryptic shorthand here, perhaps).

The other way of writing it seems equally cryptic ;-)


: Any help would be appreciated, also on what code around this
: to read from and write back the substitution to a file 
: might look like.


Sorry, I don't understand this last question.

Probably because a 'substitution' is a verb (an action) and you 
usually read/write nouns (things, like lines, characters...)

Do you mean:

"what code around this to read the string and write it again after
the substitution is done"?


while (<>) {
   while (s/ (\d) (\d\d\d) (!?\d)/($1,$2)/)  {}
   print;
}


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: Mon, 19 May 1997 23:24:26 GMT
From: lor3en@wombat.net (Loren Davidson)
Subject: WinNT: getting File Last Modified data from outside current directory
Message-Id: <5lqne3$qbm$1@ccnet2.ccnet.com>

I'm attempting to do file synchronization of about five directories from one 
NT machine to another, and discovered something odd in the process.

Using something like print ("-M $filename") for a list of files in the 
currently logged directory gives the appropriate number of days since last 
modification of all files in that directory.

Using the same function on files in any other directory gives null values.

system("cd <otherdirectory>"), which under UNIX would move me to the 
appropriate directory as a way around this, doesn't seem to work under NT.

I'm trying to only update those files which have been modified since the last 
"sweep" of the program, which will be run continuously as a service with 
various "time out" intervals for different directories.

Assistance would be appreciated.

TIA,

Loren

--
Loren Davidson      
loren@wombat.net         http://www.batnet.com/beauty/
The 3 in the header is silent...and a SPAM filter
"The future isn't what it used to be" -- Amb. G'Kar


------------------------------

Date: Mon, 19 May 1997 22:30:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Year 2000 compliance
Message-Id: <EAG968.88y@nonexistent.com>

On 19 May 1997 19:11:48 GMT, Scratchie wrote in comp.lang.perl.misc
URL: news:5lq8lk$roj$3@kayrad.ziplink.net:
++ A. Deckers <I-hate-cyber-promo@man.ac.uk> wrote:
++ 
++ : Not unless you use Perl to create one. The date and time functions
++ : supplied with perl (gmtime and localtime) supply adequate information
++ : to determine the year well beyond 2000 (2038 is when trouble strikes).
++ 
++ Forgive me for asking (since it's not in the FAQ) but how then do you deal
++ with the year 2038 problem? (Assuming you're not on a 64-bit machine by
++ then).

I guess by that time vendors will put in patches in their kernels to
deal with it. AFAIK, perl just uses low level routines to get the
localtime, and is at the mercy of your OS to supply the correct time.



Abigail


------------------------------

Date: 20 May 1997 00:11:28 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Year 2000 compliance
Message-Id: <5lqq7g$jsj$1@marina.cinenet.net>

Scratchie (upsetter@zip1.ziplink.net) wrote:
: A. Deckers <I-hate-cyber-promo@man.ac.uk> wrote:
: : Not unless you use Perl to create one. The date and time functions
: : supplied with perl (gmtime and localtime) supply adequate information
: : to determine the year well beyond 2000 (2038 is when trouble strikes).
: 
: Forgive me for asking (since it's not in the FAQ) but how then do you deal
: with the year 2038 problem? (Assuming you're not on a 64-bit machine by
: then).

Hey, we have to leave our children and grandchildren *some* interesting 
problems to work on! :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


------------------------------

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 501
*************************************

home help back first fref pref prev next nref lref last post