[6388] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 13 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 18:17:17 1997

Date: Tue, 25 Feb 97 15:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 25 Feb 1997     Volume: 8 Number: 13

Today's topics:
     "Programming Perl" (Robert Michael Slade)
     Re: [Q] Pattern Matching with Lists? <fawcett@nynexst.com>
     Alarm signal caught--program dies <mccrory@fnal.gov>
     Re: Coding question <rdarnese@nortel.ca>
     CRC or checksum <flanagan@twisto.compaq.comm>
     Re: Email Problem <hub@club-internet.fr>
     Re: File access time (Honza Pazdziora)
     help on error message (Keith Warner Colvin)
     Re: How to spam - legitimately <ajohnson@gpu.srv.ualberta.ca>
     How would I write this more concisely (Gene Johannsen)
     Install Perl for Win32 <scott.bentley@oc.edu>
     Re: Least-Squares/Kalman filter <fawcett@nynexst.com>
     Re: memory leak in HTML::LinkExtor (Matthew Ahrens)
     Re: Multi-line processing <tchrist@mox.perl.com>
     need help yncera@ids2.idsonline.com
     Re: perl forking problem <hub@club-internet.fr>
     Re: Q: How to delete several files in one operation (ne (Honza Pazdziora)
     Re: Reading formatted (13.6E) data <jander@ml.com>
     Re: regexp's in XEmacs vs. Perl <jander@ml.com>
     Re: Regular Expression question (Jeffrey)
     Re: replaceing stuff (Nathan V. Patwardhan)
     Re: The Disappearing DOS box and cmd32.exe. (Gregory Goodwin)
     Re: Using a variable for mode in chmod and mkdir <jander@ml.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 25 Feb 1997 22:08:38 GMT
From: rslade@vcn.bc.ca (Robert Michael Slade)
Subject: "Programming Perl"
Message-Id: <5evnt6$e2c@milo.vcn.bc.ca>

BKPRGPRL.RVW   961108
 
"Programming Perl", Larry Wall/Tom Christiansen/Randal L. Schwartz, 1996,
1-56592-149-6, U$39.95/C$56.95
%A   Larry Wall
%A   Tom Christiansen
%A   Randal L. Schwartz
%C   103 Morris Street, Suite A, Sebastopol, CA   95472
%D   1996
%G   1-56592-149-6
%I   O'Reilly & Associates, Inc.
%O   U$39.95/C$56.95 800-998-9938 707-829-0515 fax: 707-829-0104 nuts@ora.com
%P   670
%T   "Programming Perl"
 
Programmers!  Hackers!  Computer users of all levels!  What if we told you
there was a language that made easy things easy to program, but could handle
tough jobs too!  (And it won't clog your pipes!)  What if we told you it was
written by a linguist who tried to make sure that it was actually hard to make
a syntax error!  What if we told you it was the language of choice for Web
scripts and forms!(1)  How much would you pay?
 
Well, you don't have to!  It's free!
 
But wait!  There's more!  What if this language also had a friendly and
humorous tutorial book!(2)  *Now* how much would you pay?
 
But wait!  There's more!  What if we told you the *reference* manual for the
language was actually readable!  What if we told you that you actually *want*
to wade all the way through it as recreational reading so that you wouldn't
miss any of the jokes!  You wouldn't believe us, that's what!(3)  *Now* how
much would you pay?
 
Call now!  Since you got that hot-shot programming job your mother never hears
from you!
 
 
(1) No, don't give us that about Java.  What about all those ISPs still giving
out Netscape 1.1, or all the people who hang out on Freenets and use lynx?
 
(2) "Learning Perl", cf. BKLRNPRL.RVW
 
(3) Except, of course, for those who know of other writings by Wall or
Schwartz, or who have seen the collection of "Wallisms" that circulates on the
net.
 
copyright Robert M. Slade, 1996   BKPRGPRL.RVW   961108
 
======================
roberts@decus.ca           rslade@vcn.bc.ca           rslade@vanisl.decus.ca
              Ceterum censeo CNA Financial Services delendam esse
  Please note the Peterson story - http://www.netmind.com/~padgett/trial.htm




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

Date: 25 Feb 1997 13:42:20 -0500
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: [Q] Pattern Matching with Lists?
Message-Id: <8ju3n07mnn.fsf@nynexst.com>

Paul Felton <pf@sys.uea.ac.uk> writes:
> I want to do something like this:
>   if ($list =~ /@MONTHS.*@MONTHS/)
> where @MONTHS = ('Jan','Feb','Mar','Apr','May','Jun',etc);
> 
> This is a simple example (I don't actually want to use months) but it 
> illustrates the principle.  I know it could be written as:
>   if ($list =~ /(Jan|Feb|Mar|Apr|May|June|etc).*(Jan|Feb|etc)/)
> but this is a bit cumbersome and could become quite nasty with the lists
> I actually want to use!  I also need to extract which member of
> the list it matched with.
> 
> Is this possible or am I trying to push the language too far?

I don't think it's possible to match array elements, but it's little work
to build the regular expression:

$anymonth  = "(" . join('|', @MONTHS) . ")";
 ...
if ($list =~ /$anymonth.*$anymonth/o) {




-Tom


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

Date: Tue, 25 Feb 1997 15:23:49 -0600
From: Elliott McCrory <mccrory@fnal.gov>
Subject: Alarm signal caught--program dies
Message-Id: <33135865.4E7E@fnal.gov>

How do I catch an alarm signal and continue on?  Here is the perl:

#!/usr/local/ap/bin/perl

$sec = 10;
$SIG{ALRM} = \&mysub;

alarm $sec;
print "Waiting\n";
while (<>) {
    print "Line read $_";
}

sub mysub {
    print "Alarm signal caught\n";
    return;  # Effect is the same with and without this return
}

And it runs like this:

solaris$ test-alarm.pl
Waiting
Write a line while I wait
Line read Write a line while I wait
Alarm signal caught
solaris$

It exits immediately after catching signal.
-- 
Elliott S. McCrory, Ph. D.	| mccrory@fnal.gov
Fermi National Accelerator Lab	| http://www-linac.fnal.gov/~mccrory
MS 307, PO Box 500		| Phone: 630-840-4808
Batavia, IL  60510		| FAX: 630-840-8590


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

Date: 25 Feb 1997 21:04:48 GMT
From: Richard Arnesen <rdarnese@nortel.ca>
Subject: Re: Coding question
Message-Id: <5evk5g$2vi@nrtphc11.bnr.ca>

Richard Arnesen <rdarnese@nortel.ca> had nothing better to do and thus wrote:
: Just a quick one.

: I have a a script that basically sprouts off an external process (in
: this case xcb).  I want the process to die once the user of the script
: clicks once on the xcb program.  Is there an EASY way to do such
: a thing.

Either that OR will allow me to sense the presence of the open process
of xcb and then send my new input into it.

: TIA

: -- 
: <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
: <>Richard D. Arnesen Jr.  <> "There's too much personal freedom.  <>
: <>Unix DCA Support        <> We have to find a way to limit it.   <>
: <>Nortel, RTP, NC         <> Bill Clinton, Apr,19 1994 speaking   <>
: <>My opinions only        <> on the bill of rights.               <>
: <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>


-- 
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
<>Richard D. Arnesen Jr.  <> "There's too much personal freedom.  <>
<>Unix DCA Support        <> We have to find a way to limit it.   <>
<>Nortel, RTP, NC         <> Bill Clinton, Apr,19 1994 speaking   <>
<>My opinions only        <> on the bill of rights.               <>
<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>



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

Date: Tue, 25 Feb 1997 22:20:22 GMT
From: Brian Flanagan <flanagan@twisto.compaq.comm>
Subject: CRC or checksum
Message-Id: <331365A6.41C67EA6@twisto.compaq.comm>

Hi,

I would like to generate a semi-unique number for a
large array of strings and integers, using a CRC or 
checksum algorithm.  I think I will need to use pack,
but don't know how to do any byte operations on its
return value.  Any suggestions would be helpful.

-- 
Brian


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

Date: Sun, 23 Feb 1997 06:26:18 +0100
From: Nicolas Hubert <hub@club-internet.fr>
To: Pat Kolis <kolis@fast.net>
Subject: Re: Email Problem
Message-Id: <330FD4FA.1BBE4B1D@club-internet.fr>

Try adding the following 3 lines after your print MAIL<<EOM;
From: <from_address>
Subject: The subject
<blank line>

Hope this helps

Nicolas

Pat Kolis wrote:
> 
> Hi,
> 
> I created a relatively simple form to capture information and then send an
> email to somebody.  The form and CGI/Perl program work fine with one exception.
> When the email is sent and ultimately received, it lacks a subject and a from
> address.
> 
> Does anyone know how to set these parameters?  Code listed below.  Thank you.
> 
> #!/usr/local/bin/perl
> push(@INC, "/cgi-bin");
> require("cgi-lib.pl");
> &ReadParse(*input);
> 
>         open (MAIL, "|mail jones\@nuwave.com");
> 
>                 print MAIL <<EOM;
> 
>                            Name: $input{'name'}
>                         Address: $input{'address'}
>                         Address: $input{'address2'}
>                            City: $input{'city'}
>                           State: $input{'state'}
>                             Zip: $input{'zip'}
>                           Phone: $input{'phone'}
>                             Fax: $input{'fax'}
>                           Email: $input{'email'}
> 
>                    Comments: $input{'comments'}
> 
> EOM


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

Date: Tue, 25 Feb 1997 15:18:58 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: File access time
Message-Id: <adelton.856883938@aisa.fi.muni.cz>

jhamlin@ai.uga.edu (Jon Hamlin) writes:

> How can I get a file's access time (not modification time) in Perl?
> utime allows it to be changed, but I need to read it, not write it.

You either use the -A test or the stat function.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Tue, 25 Feb 1997 11:11:54 -1000
From: colvin@aloha.net (Keith Warner Colvin)
Subject: help on error message
Message-Id: <colvin-2502971111540001@hawaii-63.u.aloha.net>

Aloha from Hawai'i.....

>Code

  sub open_error
    {

# Assign to the local variable $file_name, the filename that we passed
# to this subroutine from the referenceing routine.

    local ($filename) = @_;

# Let the client know that the script was unable to open the requested file
# and then die so that the routine does not continue

    print "I am really sorry, but for some reason I was unable to open
    <P>$filename<P>  Would you please make sure that the filename is
    correctly defined in define_variables.pl, actually exists, and has the
    right permissions relative to the web browser.  Thanks!";
    die;
    }


> I Run my script and I get this:

Content-type: text/html

I am really sorry, but for some reason I was unable to open
    <P>./User_carts<P>  Would you please make sure that the filename is
    correctly defined in define_variables.pl, actually exists, and has the
    right permissions relative to the web browser.  Thanks!# Died.
File ':cgi-lib.sol'; Line 71

What do I do next?

Mahalo.


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

Date: Tue, 25 Feb 1997 16:10:51 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: How to spam - legitimately
Message-Id: <3313636B.645F35A@gpu.srv.ualberta.ca>

Tim Pierce wrote:
> 
> In article <pudge-ya02408000R2402971534480001@news.idt.net>,
> Chris Nandor <pudge@pobox.com> wrote:
> 
> >If this were a language with a more full tense structure, we would have two
> >plural forms, one for "email" and one for "pieces of email."  But we do
> >not.  And since we are too lazy to say "pieces of email," "emails" will
> >have to suffice.  You can't stop it.  Don't even bother trying.
> 
> If this were actually happening, I would tend to agree with you.
> But so far, I know no native speaker of English who uses the
> plural term ``emails'' when referring to distinct electronic mail
> messages, so I tend to doubt this analysis.  Tom is right to
> object to its use.
> 
my two-cents,

It is quite likely that the problem originates in the
"mis-usage" of email as a singular noun where it doesn't
sound so dreadful to the ear, for example, how often
do we see:

   "if that doesn't help, send me an email and I'll..."
   
tacked on to a reply to a newgroup question? From this,
people use the general plural rule and get "one email",
"two emails", without thinking that "one email" might not
have been "proper". So, while "emails" for many email 
messages might not be sweeping the language, "an email" is
often used and leads to people wondering how to refer to
some particular quantity of email messages. It seems, no 
one has a problem when the quantity itself is not specified:
as in "I just got some email" "I have lots of unanswered 
email..." where the usage follows "mail", but then have 
problems where "mail" wouldn't fit; "I still need to send
out 3 email to everyone on the list". Because it doesn't
fit either.

Although 'send me an email' doesn't sound that bad, no one
would say 'send me a mail'. Though we could use the verb form
'mail me and I'll...' short for 'mail me a letter and I'll...' 
which turns into 'email me and I'll...'. Personally, 'emails'
sounds awful to me, but I have been guilty of singularizing
it as above. So in the interests of preventing widespread
"emails", I'll keep an eye on my singular usage. If I transgress
just email me.

andrew


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

Date: 25 Feb 1997 22:33:39 GMT
From: gej@spamalot.mfg.sgi.com (Gene Johannsen)
Subject: How would I write this more concisely
Message-Id: <5evpc3$ip9@murrow.corp.sgi.com>

What would be a more concise way of writing this?  I'm not looking for
anything obfuscated, just something a little shorter and a little
clearer:


if ($#ARGV == -1) {
    $sked_file = "sked";
}
else {
    $sked_file = shift;
}

if ($#ARGV == -1) {
    $min = 5;
}
else {
    $min = shift;
}


It just parses two command line arguments, a filename and a time, both
of which are optional.

Thanks.

gene


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

Date: 25 Feb 1997 22:28:55 GMT
From: "Gomez" <scott.bentley@oc.edu>
Subject: Install Perl for Win32
Message-Id: <01bc236b$cac03c00$1dd88fcd@sbentley.oc.edu>

I've read every FAQ I can get my hands on and still i'm stuck. I've
installed Perl5 for Win32 on my NT server (running NT 4.0 and IIS). When I
call a perl script from an html file I never get any response back. Looking
at the task manager in NT reveals that perl.exe has been executed so I know
all of my associations are okay (although I'm unable to terminate perl) And
all of the registry entries are there. I've restarted the web service.
Still I dont get any response back and perl just runs forever. And for the
record, here's my script:

print "Content-type: text/html\n\n";
print "Hello, World!\n";

Any help would be greatly appreciated.



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

Date: 25 Feb 1997 15:33:04 -0500
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: Least-Squares/Kalman filter
Message-Id: <8jlo8c7hj3.fsf@nynexst.com>

idoh@news.intelsat.int (Haisam K. Ido) writes:
> 
> I checked out CPAN before this question :-).
> 
> Is anyone aware of a perl module that can do batch least squares, 
> weighted least squares, and/or recursive least squares ...?

Statistics::
::Descriptive  RdpO  Descriptive statistical methods              JKAST



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

Date: Tue, 25 Feb 1997 22:19:56 GMT
From: matt@callnet.com (Matthew Ahrens)
Subject: Re: memory leak in HTML::LinkExtor
Message-Id: <33146232.150357665@news.alt.net>

On 25 Feb 1997 14:56:13 +0100, Gisle Aas <aas@bergen.sn.no> wrote:

>matt@callnet.com (Matthew Ahrens) writes:
>
>> if I do this:
>> 
>> $p = HTML::LinkExtor->new;
>> 
>> and then do the following many times on different $in's:
>> 
>>     $p->parse($in);
>>     my @links = $p->links;
>> 
>> then my perl script's memory size grows continually. When I use the
>> debugger, I see that $p has an increasing number of empty arrays in it as my
>> program continues to run.
>
>The arrays should not be empty unless you have emptied them yourself.
>Remember that array elements will be shared between the array returned
>by $p->links and the internal array maintained by $p.  It is also true
>that the array will grow as it finds more links in the parsed HTML.

I don't completely understand you here, @links gets destroyed when it goes
out of scope, and it seems like $p undefs the old values insted of
truncating the list. For example, when i ran it under the debugger, letting
my program run for just a few $p->parse($in) cycles, this is what $p looks
like: (it seems that elements 0 through 21 of $p->{links} are unnecessary)

  DB<3> X p
$p = HTML::LinkExtor=HASH(0x345abc)
   '_buf' => '
'
   '_netscape_comment' => 0
   'extractlink_base' => undef
   'extractlink_cb' => undef
   'links' => ARRAY(0x484864)
      0  ARRAY(0x48487c)
           empty array
      1  ARRAY(0x484828)
           empty array
      2  ARRAY(0x4848f4)
           empty array
      3  ARRAY(0x4848e8)
           empty array
      4  ARRAY(0x4848d0)
           empty array
      5  ARRAY(0x484978)
           empty array
      6  ARRAY(0x48499c)
           empty array
      7  ARRAY(0x4849f0)
           empty array
      8  ARRAY(0x484a2c)
           empty array
      9  ARRAY(0x484a68)
           empty array
      10  ARRAY(0x484aa4)
           empty array
      11  ARRAY(0x484ae0)
           empty array
      12  ARRAY(0x484b1c)
           empty array
      13  ARRAY(0x484b58)
           empty array
      14  ARRAY(0x4811cc)
           empty array
      15  ARRAY(0x4811a8)
           empty array
      16  ARRAY(0x48119c)
           empty array
      17  ARRAY(0x48131c)
           empty array
      18  ARRAY(0x484dfc)
           empty array
      19  ARRAY(0x484f1c)
           empty array
      20  ARRAY(0x484f88)
           empty array
      21  ARRAY(0x484f4c)
           empty array
      22  ARRAY(0x487c10)
         0  'services.html'
      23  ARRAY(0x484e74)
         0  'media/index.html'
      24  ARRAY(0x487c64)
         0  'media/tech.html'
      25  ARRAY(0x487ca0)
         0  'media/jobs.html'
      26  ARRAY(0x487cdc)
         0  'media/market.html'
      27  ARRAY(0x487d18)
         0  'media/fair.html'
      28  ARRAY(0x487d54)
         0  'alpha.html'
      29  ARRAY(0x487e98)
         0  'mailto:webmaster@futuris.net'
      30  ARRAY(0x487ed4)
         0  'services.html'
      31  ARRAY(0x487f10)
         0  'futlogo1.gif'
      32  ARRAY(0x487f4c)
         0  'services.html'
      33  ARRAY(0x487c34)
         0  'media/fm2.jpg'
      34  ARRAY(0x4b4410)
         0  '/media/index.html'
      35  ARRAY(0x487fe8)
         0  'media/special.html'
      36  ARRAY(0x487e80)
         0  'media/ft.jpg'
      37  ARRAY(0x4b44c4)
         0  'media/tech.html'
      38  ARRAY(0x4828dc)
         0  'href'
         1  'media/fair.html'
      39  ARRAY(0x487ebc)
         0  'src'
         1  'media/fc.jpg'
      40  ARRAY(0x4828e8)
         0  'href'
         1  'media/fair.html'
      41  ARRAY(0x4b4590)
         0  'href'
         1  'media/jobs.html'
      42  ARRAY(0x4b4440)
         0  'src'
         1  'media/fj.jpg'
      43  ARRAY(0x4b45c0)
         0  'href'
         1  'media/jobs.html'
      44  ARRAY(0x4b447c)
         0  'src'
         1  'media/fm2.jpg'
      45  ARRAY(0x4b2ac8)
         0  'href'
         1  'media/market.html'
      46  ARRAY(0x167148)
         0  'href'
         1  'media/fyi.html'
      47  ARRAY(0x167130)
         0  'src'
         1  'media/fyi.jpg'
      48  ARRAY(0x4b2b70)
         0  'href'
         1  'media/fyi.html'
      49  ARRAY(0x4a7c58)
         0  'href'
         1  'mailto:webmaster@futuris.net'
      50  ARRAY(0x4a7cb8)
         0  'href'
         1  'mailto:fdesign@rootsworld.com'
  DB<4> 

>
>What do you suggest?  Should $p->links also truncate the list of
>links?  Should there be a separate method to truncate the link list?

How about if $p->parse() cleans out the list? This seems to make the most
sense to me, that way you can call $p->links multiple times if you want. 

>
>> To fix this problem, I just use 
>> my $p = HTML::LinkExtor->new;
>> in the subroutine which processes each $in, so that $p gets thrown away and
>> recreated often.
>
>This should not be too expensive.  Object creation in perl is fairly
>light weight.

Yes, I realize this and so creating a new $p doesn't bother me that much,
but it seems that $p does not behave nicely, so I thought I would let you
know.

>
>> Although the fix is easy, I don't see why there needs to be this memory
>> leak. I hope that this post will bring this to the author's attention.
>
>It has, but I am not sure I should do anything about it...  I might be
>in favour of making $p->links truncate the list.
>
>-- 
>Gisle Aas <aas@sn.no>



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

Date: 25 Feb 1997 21:28:36 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Multi-line processing
Message-Id: <5evli4$2ml$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Daniel Mills <dmills@riag.com> writes:
:How would I set up the following example to strip out all comments from
:a C program including those that extend over multiple lines of the input?
:I can't seem to make /m modifier work.

Why are you thinking that /m to change pattern matching on dot matching
newline has anything whatsoever to do with the $/ variable that controls
how much you read at a time?

This is included in the perlop man page (surely you read it!?), or just 
from the command line:

  perl -0777 -pe 's{/\*.*?\*/}{}gs' foo.c


--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "You can only measure the size of your head from the inside." --Larry Wall


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

Date: Wed, 26 Feb 1997 01:04:49 GMT
From: yncera@ids2.idsonline.com
Subject: need help
Message-Id: <5evnho$8op@nntp.idsonline.com>

If I put  $Imput=<> it will wait there until I hit any keys follow by
the enter key. How can I get only just one key without having to use
the enter key. I am using Perl 5.
Julio



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

Date: Sun, 23 Feb 1997 06:22:36 +0100
From: Nicolas Hubert <hub@club-internet.fr>
To: "Derek A. Crovo" <s14237dc@umassd.edu>
Subject: Re: perl forking problem
Message-Id: <330FD41C.5FBFD362@club-internet.fr>

if( $pid = fork ) {
         # Parent
         wait;
         ^^^^^
         exit(0);

There's your problem. Each time you fork, your parent does a blocking
wait for the child to terminate. What you might do is to store all your
forked pids in an array, and put you "wait" in a loop in your parent
after you've forked all your children.

Something like :
%pid=();
foreach $host ("host1", "host2", etc... ) {
    if( $pid{$host} = fork ) {
        # Parent
        exit(0);
    } elsif( defined $pid ) {
        do_some_stuff;
        exit(0);
    }
}

foreach $host ("host1", "host2", etc... ) {
    wait;
}

Hope this helps,

Nicolas

Derek A. Crovo wrote:
> 
> I've written a small perl program that does a rsh to a bunch of other
> machines on a lan.  The way I do it now is:
> $result = `rsh $host last | grep $ARGV[0] | head -n 1`;
> 
> I want all the rsh's to happen at the same time, so I don't have to wait
> so long for the output.  I tried putting each rsh into child processes,
> but it seems to fork off a child, and wait for it to complete before it
> forks the next one.  Any ideas?  Here's what I tried and still got the
> waits:
> 
> foreach $host ("host1", "host2", etc... ) {
>     if( $pid = fork ) {
>         # Parent
>         wait;
>         exit(0);
>     } elsif( defined $pid ) {
>         $result = `rsh $host last | grep $ARGV[0] | head -n 1`;
>         if( $result ) {
>             $result = substr( $result, 40 );
>             chop( $result );
>         } else {
>             $result = "Never logged in."
>             }
>         print "$host:   \t$result\n";
>         exit(0);
>     }
> }
> 
> I think the problem is that perl waits for anything in backticks (or in
> a system() call) to finish before it goes on.  But I have no idea how to
> fix it.
> 
> Thanks in advance,
> Derek Crovo


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

Date: Tue, 25 Feb 1997 15:23:39 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Q: How to delete several files in one operation (newbie)
Message-Id: <adelton.856884219@aisa.fi.muni.cz>

sajaa@sn.no (Jarle Aasland) writes:

> Here is what I have done so far:
> 
> I have a script that generate text-files from user input. Then it
> reads all the text-files and put the content into dynamically
> generated web-pages (with x-number of files on each page).
> 
> Then, I have a script that lists all the generated text-files (output
> to another html-page). From here, it's possible to edit or delete each
> individual text-file.
> 
> Problem: I can now delete each file by itself (by clicking it's
> respective "Delete" link), but what I want to do is choose several
> files, and then "Delete all marked files".

Good news: perl's function unlink can have a list of files to delete,
	so you only need one function call.
Bad news: if you are more like asking how to create a list in a HTML
	form and enable that selection and run a cgi script to do
	that, you have to find another newsgroup, with something like
	.cgi. in its name.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 25 Feb 1997 17:15:23 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: Reading formatted (13.6E) data
Message-Id: <wkbg1yksfb8.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Jerry Anders <anders@ix.netcom.com> writes:

> The data that I'm trying to read is formatted in 10 columns and is in 13.6E format. The following is an example:
> 
>  0.111000E+01-0.112000E+01 0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01 0.117000E+01 0.118000E+01 0.119000E+01-0.111000E+01
>  0.121000E+01 0.122000E+01 0.123000E+01-0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
>  0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
>  0.111000E+01 0.112000E+01-0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01-0.117000E+01 0.118000E+01 0.119000E+01 0.111000E+01
>  0.121000E+01 0.122000E+01 0.123000E+01 0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
> -0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
>  .
>  .
> 
> If the data came across the net properly you should see blocks of data in 10 columns and each block has 26 numbers.
> 
> My question is, instead of reading the file line by line and then breaking that line ($_) down into numbers, can I read the file
> number by number. Can I modify the input record separator ($/) such that it interprets 13.6E format instead of creating elaborate loops 
> which read every character or blocks of 13 characters? Is there and easier way to extract the data number by number? 
> 
> An example of what I'm doing with the data is, lets say, extract every 3, 6, 10-15, 20-22, number from each block and stuff them into and 
> array (i.e., extract protions of this data and save them in an array). Since I have lots of data which uses strict formats (engineering data) 
> as shown above, I'd like a solution which uses formats such as %13.6E. I understand how to print using formats, but can I read using formats?

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

my @nums;

while (<DATA>) {
  push @nums, unpack "a13a13a13a13a13a13", $_;
}

foreach (@nums) {
  print "$_\n";
}

__DATA__
 0.111000E+01-0.112000E+01 0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01 0.117000E+01 0.118000E+01 0.119000E+01-0.111000E+01
 0.121000E+01 0.122000E+01 0.123000E+01-0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
 0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
 0.111000E+01 0.112000E+01-0.113000E+01 0.114000E+01 0.115000E+01 0.116000E+01-0.117000E+01 0.118000E+01 0.119000E+01 0.111000E+01
 0.121000E+01 0.122000E+01 0.123000E+01 0.124000E+01 0.125000E+01 0.126000E+01 0.127000E+01 0.128000E+01 0.129000E+01 0.121000E+01
-0.131000E+01 0.132000E+01 0.133000E+01 0.134000E+01 0.135000E+01 0.136000E+01
=========================================================================


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

Date: 25 Feb 1997 21:35:30 +0000
From: Jim Anderson <jander@ml.com>
Subject: Re: regexp's in XEmacs vs. Perl
Message-Id: <wkbohd8sh5p.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

Matthew.Healy@yale.edu (Matthew D. Healy) writes:

> <flamebait>
> Silly me, I use vi...
> </flamebait>
> 
> :-) :-} :-O :-] :-() :-%} :-%>

Well, we all have our problems :)


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

Date: 25 Feb 1997 18:48:45 GMT
From: jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey)
To: riekhof@primenet.com
Subject: Re: Regular Expression question
Message-Id: <JFRIEDL.97Feb26034845@tubby.nff.ncl.omron.co.jp>


[mail and post]

Darrel Riekhof <riekhof@primenet.com> wrote:
|> > Perl doesn't really match the longest possible string (maybe Jeffrey
|> > will jump in here?).
|> 
|> This seems inconsistent.  I tested it on (a)* and (a*), and each one
|> returned 'a' in $1.  I would have thought (a*) would match '' the
|> last time.

This is completely consistant. Consider:

With (a)*, the contents of the parens is the regex /a/, so what that
matches is what $1 will be (if there is a match, of course). Thus,
$1 can be only "a" if there is a match.

With (a*), the contents of the parens is the regex /a*/, so what that
matches is what $1 will be. This can be "", "a", "aa", "aaa", etc.,
depending on the string. If your string was "a", then it will be "a".

|> Then I tried (a*)* and $1 had ''.

Yup. $1 can be filled by /a*/, and that can match "".

|> Finally I tried (a)** and got a nesting error.

As you should.

|> Is there a source that explicitly states how perl5 behaves in these
|> situations?

FWIW, it's covered on page 218 of my book.

|> IMO, the most logical behavior would be for any 
|> expression inside parens with a global asterisk, (<expr>*), to return
|> '' in its backref.

So you're saying that
	"word" =~ m/(\w*)/
shouldn't set $1 to "word"???

	Jeffrey
----------------------------------------------------------------------------
Jeffrey Friedl <jfriedl@omron.co.jp> Omron Corp, Nagaokakyo, Kyoto 617 Japan
See my Jap<->Eng dictionary at http://www.wg.omron.co.jp/cgi-bin/j-e
O'Reilly's Regular Expression book: http://enterprise.ic.gc.ca/~jfriedl/regex/


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

Date: 25 Feb 1997 21:56:02 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: replaceing stuff
Message-Id: <5evn5i$jtj@fridge-nf0.shore.net>

Vetle Roeim (vetler@ifi.uio.no) wrote:


: the only problem i have, is that i don't know how i should
: delete everything exept the link from a variable.

Try this out:

#!/usr/local/bin/perl5 -w ### or your path here

$html = "bookmarks.html";
$out = "out.lnk";

# regexp to parse anything in hrefs.
#$link =~ s/<(.*?)"(.*?)" (.*?)>.*?<\/(.*?)>/$2/g;

open(IN, "$html") || die("$!\n");
@lines = <IN>;
close(IN);

open(OUT, ">$out") || die("No: $!\n");
foreach $link (@lines) {
    if($link =~ /http/i) {
        $link =~ s/<(.*?)"(.*?)" (.*?)>.*?<\/(.*?)>/$2/g;
	$link =~ s/(\s+)//g;
        print OUT $link,"\n";
        print $link,"\n";
    }
}
close(OUT);

HTH!

--
Nathan V. Patwardhan
nvp@shore.net
"Lane, I've been in high school for
seven years.  I'm no dummy"
	--Charles Demar from _Better Off Dead_


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

Date: Tue, 25 Feb 1997 22:48:08 GMT
From: gm-goodwin@worldnet.DOT.att.DOT.net (Gregory Goodwin)
Subject: Re: The Disappearing DOS box and cmd32.exe.
Message-Id: <33146c1d.170222096@netnews2.worldnet.att.net>

Thanks Simon.  Great suggestion!   It sounds like it just might do the
trick.  I just downloaded it and will give it go this weekend.

Thanks again.  It is very much appreciated.

--
Gregory 

(e-mail address altered for the benefit of spammers)


On Mon, 24 Feb 1997 12:56:03 +0000, Simon Griffiths
<griffithss@entcf1.agw.bt.co.uk> wrote:

>Gregory Goodwin wrote:
>> 
>> The problem though is that the DOS box disappears too fast to read.  I
>> can add a sleep command, but that only works ............
>
>You may like to try Alan Phillips' excellent Programmer's File Editor
>available from http://www.lancs.ac.uk/people/cpaap/pfe/. This has an
>option which allows perl to be run in a DOS window whilst all terminal
>output is collected. After the run is complete the editor also open a
>new edit window and displays the command output. 
>
>PFE seems to me to be an excellent MS-windows editor and I use it
>constantly to write perl, java, SQL and much else. I use it on NT 3.51,
>Windows95 and Win3.11.
>
>Simon.



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

Date: 25 Feb 1997 16:41:17 -0500
From: Jim Anderson <jander@ml.com>
Subject: Re: Using a variable for mode in chmod and mkdir
Message-Id: <wkblo8csgw2.fsf@swapsdvlp15.i-did-not-set--mail-host-address--so-shoot-me>

"Robert A. Goff" <ragoff@sandia.gov> writes:

> I need help using a variable for the mode parameter in chmod and mkdir,
> e.g.
> 
> $dirmode = '0777';
> $filemode = '0755';
> mkdir("$FORM{'cwd'}/$FORM{'dirname'}", $dirmode);
> chmod($filemode, "$FORM{'cwd'}/$FORM{'filename'}");
> 
> which results in a file/directory with the wrong mode.  Using the
> literal octal numbers gets me the right mode, so I obviously don't know
> how to cast a variable to an octal value.  Any help appreciated,
> including telling me which part of TFM to R.

Blue Camel, p. 40

$dirmode = '\0777';
$filemode = '\0755';


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 13
************************************

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