[7659] in Perl-Users-Digest
Perl-Users Digest, Issue: 1285 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 7 10:17:17 1997
Date: Fri, 7 Nov 97 07:00:46 -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 Fri, 7 Nov 1997 Volume: 8 Number: 1285
Today's topics:
Re: An excellent example of perl madness (or "split stu (Tad McClellan)
Re: An excellent example of perl madness (or "split stu <Steve_Kilbane@cegelecproj.co.uk>
Re: An excellent example of perl madness (or "split stu <ghowland@hotlava.com>
Re: An excellent example of perl madness (or "split stu <Steve_Kilbane@cegelecproj.co.uk>
Re: Another batch of some simple newbie questions. :) <glenn.west@ptsc.slg.eds.com>
Re: Associative Array (HASH) problem (Toutatis)
Re: Command line options (Jim Michael)
Re: Did an open for append create the file? <rootbeer@teleport.com>
Re: Exact string matches <jamesr@aethos.co.uk>
Re: Exact string matches <Jerzy.Orzeszek@univcomp.waw.pl>
Re: Exact string matches <rootbeer@teleport.com>
File not found error <mreed@cis.ohio-state.edu>
file not found error? <mreed@cis.ohio-state.edu>
Re: Help! with CGI (Toutatis)
Re: Help! with CGI <rootbeer@teleport.com>
Re: How to send mail w/in Perl program? <jamesr@aethos.co.uk>
Re: How to set chmod before writing to a file? <rootbeer@teleport.com>
Re: interrupt system("$cmd") if timeout <helina@torus.eng.yale.edu>
Re: make ftp on perl script with windows 95/NT (Eric Bohlman)
Re: My, while, and continue <tycage@infi.net>
Re: newbie seeks standardfile.pl for MacPerl (Chris Nandor)
Re: Newbie: CGI incantations for Mac (Chris Nandor)
object serialization (Neil . Goodgame)
Perl variable filehandles <corcordt@cs.purdue.edu>
Print output contains extra characters (James Gryga)
Re: Protecting Perl Source (Paul Marquess)
semaphore in perl <wangyj@sro.cig.mcel.mot.com>
Re: semaphore in perl <mortensi@idt.ntnu.no>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 6 Nov 1997 21:08:58 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: An excellent example of perl madness (or "split stupidity")
Message-Id: <ao0u36.8l3.ln@localhost>
Bart Lateur (bart.mediamind@tornado.be) wrote:
: aml@world.std.com (Andrew M. Langmead) wrote:
: >OK, I'll be (at least one of the) people who point out the
: >documentation. The perlfunc man page says split() can be called in the
: >following forms:
: >
: > split /PATTERN/,EXPR,LIMIT
: > split /PATTERN/,EXPR
: > split /PATTERN/
: >
: >So any of your examples without a pattern as the first argument to
: >split is WRONG.
: Let me prove you wrong by pointing at the documentation, ok? (I love it
: when this happens <grin>)
: If you look a bit further down in the same documentation, you can see:
: : The pattern PATTERN may be replaced with an expression to specify
But it doesn't say that /PATTERN/ may be replaced with an expression...
: : patterns that vary at runtime. (To do runtime compilation only once,
: : use /$variable/o.)
^ ^
See? The slashes are still there ;-)
: "expression" means "a string" here (or, more general, a scalar).
: Just read the docs completely before slapping anybody around the ears
: with it, will you?
So, where in the docs _does_ it say that you can provide a string there?
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 07 Nov 1997 11:53:13 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
Subject: Re: An excellent example of perl madness (or "split stupidity")
Message-Id: <b77cd$b35d.238@news.cegelecproj.co.uk>
In article <3462F009.7A49@hotlava.com>, Gary Howland <ghowland@hotlava.com> writes:
> > Gary> A pint for anyone who can tell
> > Gary> my which three (without running the code):
> >
> > (Five, actually...)
>
> Excellent! This has caught Randal out!
Not necessarily. You first wrote:
> > Three of the following work as expected.
And Randal said five did. Presumably, you and Randal had
different expectations of what the commands would do.
> Only three work as hoped - so now do I have your sympathy?
Nope. You didn't say in advance what result you wanted, so
there wasn't a definition of "worked", apart from the default,
which is "doing what the documentation says it does."
> Life would be so much clearer if perl just refused to coerce these
> strings into regexs, and made me type them explicitly ...
Life would also be clearer if perl didn't support regexps at all,
but then perl wouldn't be nearly as useful. As it stands, you
can do:
my $pattern = "some regexp, possibly program input";
...
my @items = split($pattern,@list);
In your case, you're just missing out the middleman.
Now, this isn't to say that this isn't a good opportunity for
an extra warning message, but the conditions for generating
the warnings might be hard to detect. Your problem is
basically that you've got a literal string where a regexp is
expected, and the backslash interpretation happens for
both the double-quoted string and the regexp parser, with
different semantics.
Question is, do you warn because the double-quote removes
sequences that are regexp-special ("\s" -> /s/) or resolves to
them ("\|" -> /|/) ?
--
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.
------------------------------
Date: Fri, 07 Nov 1997 14:28:05 +0100
From: Gary Howland <ghowland@hotlava.com>
Subject: Re: An excellent example of perl madness (or "split stupidity")
Message-Id: <34631765.7570@hotlava.com>
Steve Kilbane wrote:
>
> Now, this isn't to say that this isn't a good opportunity for
> an extra warning message, but the conditions for generating
> the warnings might be hard to detect. Your problem is
> basically that you've got a literal string where a regexp is
> expected, and the backslash interpretation happens for
> both the double-quoted string and the regexp parser, with
> different semantics.
>
> Question is, do you warn because the double-quote removes
> sequences that are regexp-special ("\s" -> /s/) or resolves to
> them ("\|" -> /|/) ?
It looks like we need two warnings. A warning of the form
"possible regular expression in double quoted string" or
even "redundant backslash in double quoted string" for cases
like "\d" might make sense, and would certainly help catch a
range of silly split() errors, but what are the disadvtanges?
The second warning would be needed to inform the user that
passing '|' to split() might not do what he intends. It
should tell the user to type /|/ instead of '|'.
Why can't we add this second warning? Because too many
people out the are used to including regexs in single (or
even double) quotes? Or because we like allowing the user
more than one way to do it? (albeit at the cost of there
being more than one to get it wrong ...)
Surely it can't be too hard to program? At some point the
string is being coerced into a regex, so it must be possible
to detect if it the source string is an explicit string (as
opposed to a variable) and warn the user that they should
use an explicit regex instead?
Or is there a "legitimate" need to specify a regex as a
string?
Hmm - I've just realised it looks like we need a REGEX
type. Wasn't there some talk of make regexes first class
types a while back?
Gary (now pondering over REGEX types ...)
--
pub 1024/C001D00D 1996/01/22 Gary Howland <gary@hotlava.com>
Key fingerprint = 0C FB 60 61 4D 3B 24 7D 1C 89 1D BE 1F EE 09 06
------------------------------
Date: Fri, 07 Nov 1997 13:43:02 GMT
From: Steve Kilbane <Steve_Kilbane@cegelecproj.co.uk>
Subject: Re: An excellent example of perl madness (or "split stupidity")
Message-Id: <b77cd$d2b2.81@news.cegelecproj.co.uk>
In article <34631765.7570@hotlava.com>, Gary Howland <ghowland@hotlava.com> writes:
> It looks like we need two warnings. A warning of the form
> "possible regular expression in double quoted string" or
> even "redundant backslash in double quoted string" for cases
> like "\d" might make sense, and would certainly help catch a
> range of silly split() errors, but what are the disadvtanges?
It couldn't be a generic error, because (apart from anything else)
it would make filenames in the DOS world unusable. It's possible
that the warning could only be enabled where a regexp was
expected, but there you're getting into the internals of perl,
about which I know nothing. I don't know whether the parser
could "know" at that point that the string was originally a
double-quoted literal.
> The second warning would be needed to inform the user that
> passing '|' to split() might not do what he intends. It
> should tell the user to type /|/ instead of '|'.
Hmm. Reminiscent of the warnings for print (expr)
taken as function and literal tokens being stringified.
> Or is there a "legitimate" need to specify a regex as a
> string?
That's a question that could do with being clarified.
I'm not sure whether you mean as a string literal,
or as a generic scalar EXPR.
--
<Steve_Kilbane@cegelecproj.co.uk> - All opinions are mine alone.
Kilbane's law of integration: standardise on protocols and file
formats, and the applications take care of themselves.
------------------------------
Date: Thu, 06 Nov 1997 17:14:00 -0500
From: "Glenn A. West" <glenn.west@ptsc.slg.eds.com>
Subject: Re: Another batch of some simple newbie questions. :)
Message-Id: <34624127.77EA@ptsc.slg.eds.com>
Pelt wrote:
>
> ************************************************************************
> Hello everyone. I'm kinda new to programming in perl, working on a Sparc
> and several Sun Unix systems. I'm trying to write some code/scripts, but
> am starting to run into some annoying, simple mistakes somewhere,
> and was wondering if anyone can help me out?
>
> For one, I'm trying get the 3 letter day out of the date command. I'm
> using:
>
> $day = `date | awk '{print $1}'`
Try adding \ in front of $1. But I'm not sure why either...
>
> But the output of print $day is always the entire date command. I'm
> figuring the pipe isn't working, but I'm not sure why.
>
> Thanks in advance. :)
>
> Dave/Pelt
------------------------------
Date: 7 Nov 1997 13:22:45 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Associative Array (HASH) problem
Message-Id: <toutatis-ya023180000711971422450001@news.euro.net>
In article <34625739.1689@geocities.com>, faerielands@geocities.com wrote:
> How can I write a piece of code that will allow
> me to have two keys being the same, but have each one be associated with
> a DIFFERENT value? Is this possible? Should I use pointers? the 'each'
> command? Help!
Each key can appear only once, and can have only one value. However, each
key can contain a pointer to an array containing more values, like this:
$hash{$key} = [];
In perl, you don't first have to create this empty anonymous array: if you
haven't used $hash{$key} before, you can use it right away, as if it exists
already:
Adding items to $hash{$key}:
push @{$hash{$key}}, $item; #appending to the end of the list
See also shift, unshift and pop in your perl documentation
Reading items of $hash{$key}:
$first_value = $hash{$key}[0];
Looping though a (sorted numerically, like you requested) hash:
foreach $key(sort {$a <=> $b} keys %hash){
foreach (@{$hash{$key}}){
print "$key: $_\n";
}
}
--
Toutatis
------------------------------
Date: Fri, 7 Nov 1997 14:13:38 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Command line options
Message-Id: <genepoolEJA4ur.4oz@netcom.com>
Stephen O. Lidie (lusol@turkey.cc.Lehigh.EDU) wrote:
: Jim Michael (genepool@netcom.com) wrote:
: : kchadha@hotmail.com wrote:
: Context - scalar vs. array.
: In scalar context you get a match count. In array context you
: get the matches.
: ($arg0) = $ARGV[0] =~ s/-t//;
: ($arg1) = $ARGV[1] =~ s/-t//;
: should do it.
No, this still returns 1.
Cheers,
Jim
------------------------------
Date: Fri, 7 Nov 1997 06:27:34 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Justin Wills <justin@nectar.com.au>
Subject: Re: Did an open for append create the file?
Message-Id: <Pine.GSO.3.96.971107062022.6203F-100000@usertest.teleport.com>
On Thu, 6 Nov 1997, Justin Wills wrote:
> fred@no.spam.leeds.ac.uk wrote:
>
> > Is there an easy way to find out if the call to open() with a
> > filename starting ">>... actually created the target file.
> yeah, before you open it, say
>
> (! -f $file ) && open(FILE, ">>$file);
That's bad code for about five reasons: it's unnecessarily obfuscated,
it's nonatomic, it's reckless, it's redundant, and it doesn't do what the
poster asked.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 7 Nov 1997 11:09:55 GMT
From: "James Richardson" <jamesr@aethos.co.uk>
Subject: Re: Exact string matches
Message-Id: <01bceb6d$c4db4bc0$26c0a4c1@kitkat.aethos.co.uk>
paul@pkamf.demon.co.uk wrote in article
<878824699.9108.0.nnrp-01.9e98ada2@news.demon.co.uk>...
> Hi
>
> I am looking to match the end of a sting exactly ie I want:
>
> if($string =~ $anotherstring){
> do something;
> }
>
> This works but matches any bit of $anotherstring to $string
> eg
>
> $string = ".baker"; $ anothersting = ".ba";
>
> and gives a match. How do I code the test so that the only matches I
> get are for other strings that end in .ba alone?
>
Well, I dont really understand the question... but you can do...
if ($a eq $b) { } - To compare two strings exactly....
if ($a =~ /^$b$/) { } - To compare two strings exactly but use regexps
if ($a =~ /$b$/) { } - To match strings that end in $b
Hope that answers your question....
James
------------------------------
Date: Fri, 07 Nov 1997 14:36:04 +0100
From: Jerzy Orzeszek <Jerzy.Orzeszek@univcomp.waw.pl>
Subject: Re: Exact string matches
Message-Id: <34631944.6AAB4DBE@univcomp.waw.pl>
I need help too.
I have a script which search a file for text entered on formpage.
I have something like this:
#!/usr/bin/perl
...
...
$file = 'data.html';
&ReadParse;
$TEXT = $in{'text'};
print "Content-Type: text/html\n\n";
print $head;
open(PLIK,"$file") || die "Open $file: $!\n";
while (<PLIK>) {
if (/^<h3>([^<]+)<\/h3>/) { # find <h3> case insensitive
$found = 1 if $1 eq $TEXT; # or => $1 =~ /^$TEXT$/i
}
last if $found && /^<hr>/i; # the end of the data record
print if $found;
}
close(PLIK) || die "Close $file: $!\n";
print "$TEXT not found. ;-(<br>\n" if !($found);
But when I have an entry like this:
<H3>text-1</H3>
...
...
...
<HR>
<H3>text-2</H3>
...
...
...
<HR>
<H3>text-2</H3>
...
...
...
<HR>
<H3>text-1</H3>
...
...
...
<HR>
and would like to find and display all lines matches text-1
I recive also text-1 and following lines and next text-1 and
finaly last entry with text-1.
Can you tell me how to display all entries matching text-1 if
text-1 entry and the following lines are scatterd diffrent places
inside a data.html file.
Jerzy
> Well, I dont really understand the question... but you can do...
>
> if ($a eq $b) { } - To compare two strings exactly....
> if ($a =~ /^$b$/) { } - To compare two strings exactly but use regexps
> if ($a =~ /$b$/) { } - To match strings that end in $b
>
> Hope that answers your question....
>
> James
------------------------------
Date: Fri, 7 Nov 1997 06:50:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: James Richardson <jamesr@aethos.co.uk>
Subject: Re: Exact string matches
Message-Id: <Pine.GSO.3.96.971107064120.6203K-100000@usertest.teleport.com>
On 7 Nov 1997, James Richardson wrote:
> if ($a eq $b) { } - To compare two strings exactly....
> if ($a =~ /^$b$/) { } - To compare two strings exactly but use regexps
> if ($a =~ /$b$/) { } - To match strings that end in $b
Actually, those last two descriptions are misleading. Those two work at
all only if $b is a valid portion of a regex which may be interpolated
there. If $b contains, for example, ')', that won't do anything good.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 07 Nov 1997 08:07:40 -0500
From: Michael Reed <mreed@cis.ohio-state.edu>
Subject: File not found error
Message-Id: <3463129C.DBA@cis.ohio-state.edu>
I have a snippet of code:
chdir("/export/0/webman/checkin_server/data/") || print "1\n\n";
@sched = `/bin/cat $username.sched`; print @sched;
Which is the umpteenth version I've written trying to do the same thing.
$username="mreed"
When executed, this give a cat: file not found error. However, if I
substitute
in an actual username:
chdir("/export/0/webman/checkin_server/data/") || print "1\n\n";
@sched = `/bin/cat mreed.sched`; print @sched;
Works great. I have verified that there are no hidden characters or
training
new lines on $username. I am perplexed. Any idea why this may be
happening?
--
Michael Reed
CIS Web Manager 778 Dreese
Computer and Information Science 2015 Neil Avenue Col, OH 43012
The Ohio State University Office phone: (614)
292-1153
------------------------------
Date: Fri, 07 Nov 1997 08:10:17 -0500
From: Michael Reed <mreed@cis.ohio-state.edu>
Subject: file not found error?
Message-Id: <34631339.2CF0@cis.ohio-state.edu>
I have a snippet of code:
chdir("/export/0/webman/checkin_server/data/") || print "1\n\n";
@sched = `/bin/cat $username.sched`; print @sched;
Which is the umpteenth version I've written trying to do the same thing.
$username="mreed"
When executed, this give a cat: file not found error. However, if I
substitute in an actual username:
chdir("/export/0/webman/checkin_server/data/") || print "1\n\n";
@sched = `/bin/cat mreed.sched`; print @sched;
Works great. I have verified that there are no hidden characters or
trailing new lines on $username. I am perplexed. Any idea why
this may be happening?
--
Michael Reed
CIS Web Manager 778 Dreese
Computer and Information Science 2015 Neil Avenue Col, OH 43012
The Ohio State University Office phone: (614)
292-1153
------------------------------
Date: 7 Nov 1997 13:36:05 GMT
From: toutatis@_SPAMTRAP_toutatis.net (Toutatis)
Subject: Re: Help! with CGI
Message-Id: <toutatis-ya023180000711971436070001@news.euro.net>
Alwin Bijvoet <info@audiovisueel.com> wrote:
> Hello,
>
> I am using win95
> I installed perl for Win32 Build 306 (apr 97)
> I am using frontpage97
> The problem:
> When I try tu run a cgi-script I get the error message:
>
> CGI Error
> The specified CGI application misbehaved by not returning a complete set
> of HTTP headers. The headers it did return are:
> Can't open perl script "_vti_cnf": Permission denied
>
> What to do?
Jump out of the window.
--
Toutatis
------------------------------
Date: Fri, 7 Nov 1997 06:28:48 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Alwin Bijvoet <info@audiovisueel.com>
Subject: Re: Help! with CGI
Message-Id: <Pine.GSO.3.96.971107062827.6203G-100000@usertest.teleport.com>
On 7 Nov 1997, Alwin Bijvoet wrote:
> When I try tu run a cgi-script I get the error message:
>
> CGI Error
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN. Hope this helps!
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 7 Nov 1997 10:58:06 GMT
From: "James Richardson" <jamesr@aethos.co.uk>
Subject: Re: How to send mail w/in Perl program?
Message-Id: <01bceb6c$1c67eee0$26c0a4c1@kitkat.aethos.co.uk>
Joseph O'Rourke <orourke@grendel.csc.smith.edu> wrote in article
<34612503.0@news.smith.edu>...
> I am using Perl 5.0 on a Unix system, and would like my program
> to send me mail whose body is written from information in
> variables inside the Perl program. I tried
>
> system "mail orourke"
>
OK, hows about something like
$message = "This is the message that you want to send\n";
open(MAIL, "|mail orourke") || die "Mo mailer!\n";
print MAIL $message;
close(MAIL);
You dont say what Unix system you use, but as a general rule 'mail' doesnt
let you set the subject on the command line..
On HPUX you can use mailx with -s "Subject"
On Solaris you can use /usr/ucb/mail with -s "Subject"
James
------------------------------
Date: Fri, 7 Nov 1997 06:34:34 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: jmack@p3.net
Subject: Re: How to set chmod before writing to a file?
Message-Id: <Pine.GSO.3.96.971107063207.6203H-100000@usertest.teleport.com>
On Thu, 6 Nov 1997 jmack@p3.net wrote:
> is there a way to set the permissions of a file to 644 before it is even
> written?
You want umask(022), perhaps? Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Fri, 07 Nov 1997 07:45:57 -0500
From: Helina Chan <helina@torus.eng.yale.edu>
Subject: Re: interrupt system("$cmd") if timeout
Message-Id: <34630D84.1B4BCB7B@torus.eng.yale.edu>
Cameron Simpson wrote:
> Helina Chan <helina@torus.eng.yale.edu> writes:
> | I could not find information about interrupting
> | a process started by system("$cmd") if a specified timeout
> | occured.
> | For example, rsh will time out in 75 seconds if the
> | remote machine is down. Suppose I want to do
> | system("rsh $host $cmd");
> | and if it did not succeed in $timeout seconds, interrupt
> | the above process and print out "system is down".
>
> You need to break the system() up - internally it sort of goes
>
> Parent program Child program
>
> fork()
> --------->exec(sh,-c,$cmd)
> wait()... ... child runs ...
> exit()
> <--------
> wait() returns
> ... parent continues ...
>
> Use fork() instead of system. In the child, set an alarm for 75 seconds.
> Then wait() in the parent, more or less as normal.
>
> See fork(), exec(), alarm(), waitpid().
> --
> Cameron Simpson, DoD#743 cs@zip.com.au http://www.zip.com.au/~cs/
>
> Yesterday I saw a bumpersticker that said: "Vote from the Rooftops" followed
> by a picture of a sniper. Kinda summed it all up for me.
> - Ken Strayhorn Jr. <kes@acpub.duke.edu>
Thanks for your help. However, it does not seem to work.
The problem is that, at least tested on my linux machine,
sh spawns another process. So after the sh process timed
out, its child continues. Here is an example code:
tiger:~$ cat tmp.pl
#!/usr/local/bin/perl
if ( ( $child_id = fork() ) < 0 ) {
die "fork $!";
}
if ($child_id ) {
waitpid($child_id,0);
print "The parent reaped child $child_id, with status $?\n";
}
else {
$timeout=30;
local $SIG{ALRM} = sub { die "alarm\n" };
alarm $timeout;
exec (qq(sh -c "ls -lR / > /tmp/ls.out 2>/dev/null"));
alarm 0;
}
After starting the program, before the time out, I see that
tiger:~$ ps -aux | grep ls
helina 525 0.7 1.4 1256 568 p0 S 07:28 0:00 sh -c ls -lR / > /tmp
helina 526 42.8 1.4 1060 552 p0 D 07:28 0:03 ls -lR /
and the program terminates, after timeout, with
tiger:~$ tmp.pl
The parent reaped child 525, with status 14
So the process 526 continues on until it is finished! I would like to get
rid of that one immediately after time out.
Any further suggestions?
Thanks
Helina
------------------------------
Date: Fri, 7 Nov 1997 11:08:15 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: make ftp on perl script with windows 95/NT
Message-Id: <ebohlmanEJ9w9r.HHM@netcom.com>
Tasuka Amano Hsu (h120996667@mail.chinatrust.com.tw) wrote:
: I want make a program to do ftp to the other site on network,
: with perl script and MS-windows 95/NT how to do that ?
Use the Net::FTP module, available from a CPAN site near you.
: PS:I use Perl 5.001 on MS-Windows 95
Don't. Use 5.004 instead, also available from a CPAN site near you (in
Gurusamy Sarathy's directory).
------------------------------
Date: Fri, 07 Nov 1997 09:49:15 -0500
From: Ty Cage Warren <tycage@infi.net>
Subject: Re: My, while, and continue
Message-Id: <34632A6B.5698A562@infi.net>
Doug Harrison wrote:
>
> Is a variable declared with "my" in a while loop supposed to be
> available in the loop's continue clause? It is in Perl for Win32,
> 5.003_07, but only in the first statement of the continue clause. For
> example, when I run the following:
>
> $x = 0;
> while ($x++ != 2)
> {
> my $y = "test";
> }
> continue
> {
> print "1 $y\n";
> print "2 $y\n";
> }
>
> The output is:
>
> 1 test
> 2
> 1 test
> 2
>
> After "1 test" is printed, $y becomes empty. Anyone know what the
> expected result is?
I suspect you are becoming a victim of a bung in 5.003. My old 5.003
binary on Digital Unix did the same thing.
On the other hand, under 5.004, it gest even worse. =)
It $y is never printed and is undefined in the continue block. This is
the expected bahavior as I understand my though.
my localizes a variable to the local block. i.e. between the closest {
and }.
So the fact that 5.003 printed it at all was most likely a bug.
Anyone who actually knows what they are talking about can feel free to
correct me. =)
Hope this helps,
Ty
+---+
Ty Cage Warren tycage@infi.net
Systems Engineer InfiNet
Web Site of Love: http://tazer.engrs.infi.net/mst3k/
PGP Public Key: http://tazer.engrs.infi.net/~tycage/pgpkey.html
PGP Fingerprint: FF C1 28 CA 80 B5 31 78 B1 24 2E 8C AB DA FB D2
------------->Never invoke anything bigger than your head.<-------------
------------------------------
Date: Fri, 07 Nov 1997 09:20:59 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: newbie seeks standardfile.pl for MacPerl
Message-Id: <pudge-ya02408000R0711970920590001@news.idt.net>
In article <Pine.GSO.3.96.971106150948.7105G-100000@usertest.teleport.com>,
Tom Phoenix <rootbeer@teleport.com> wrote:
# On 5 Nov 1997, k w billerts wrote:
#
# > I am new to the Perl environment and am using MacPerl. I would like to
# > develop some basic CGI scripts and obtained the following info from a
# > MacPerl FAQ:
# >
# > 2.3.1) How do I request an input or output file under MacPerl?
# >
# > require 'StandardFile.pl';
#
# The Standard File package on the Macintosh has to do with requesting a
# filename on your local system. That is, asking for a filename from the
# person at the keyboard and mouse, not the person at the other end of a web
# connection. It's not generally useful for CGI script programming. But, if
# you do need that library file, it should have come with MacPerl. Hope this
# helps!
Absolutely correct; however, in the imminent next release of MacPerl you
will want to use Mac::StandardFile instead.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: Fri, 07 Nov 1997 09:27:21 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Newbie: CGI incantations for Mac
Message-Id: <pudge-ya02408000R0711970927210001@news.idt.net>
In article <DO_NOT_SPAM_acs-0511972349340001@acs.bitstream.net>,
DO_NOT_SPAM_schneider@pobox.com wrote:
# frogkisser@geocities.com wrote:
# > What incantations need to go before the #/whatever/bin/perl line for
# > MacPerl CGI scripts? I'm running the freeware server Quid Pro Quo 2.0
# > which should support the same cgi stuff as MacHTTP or WebStar. Thanks!
#
# You don't need a #!/whatever/perl line in MacPerl scripts. Just save them
# as CGI Scripts from MacPerl (you ARE using MacPerl 5, yes?), and fire 'em
# up!
According to Matthias Neeracher (10.14 22 Feb 1997):
# It's a good idea to include one anyway (It just has to mention perl, so
# I use #!perl usually). If you don't include one, your file will be read
# twice.
#
# The reason for this is that MPW script syntax is sufficiently
# incompatible with Perl that the only way to write MPW perl scripts is to
# write them as:
#
# Perl -Sx "{0}" {"Parameters"}; Exit {Status}
# #!perl
# ... Perl script ...
#
# In order to make this style of script writing compatible with the
# application, the application does a "soft" version of -x: Like for -x,
# the script file is searched for a #! line, but if it is not found, the
# file is simply reset. Thus, no error is noticeable, but the script file
# is read twice.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'0824 090B CE73 CA10 1FF7 7F13 8180 B6B6'])
#== MacPerl: Power and Ease ==#
#== Publishing Date: Early 1998. http://www.ptf.com/macperl/ ==#
------------------------------
Date: 07 Nov 1997 11:41:15 +0000
From: goodgn00@hau153.ha.uk.sbphrd.com (Neil . Goodgame)
Subject: object serialization
Message-Id: <v9qhg9pext0.fsf@hau153.ha.uk.sbphrd.com>
Are there any perl modules that will serialize a perl object to a file
and back again, similar to sequential_io in Ada 95.
--
======================================================
Neil Goodgame Smithkilne Beacham
Neil_Goodgame-1@sbphrd.com
======================================================
------------------------------
Date: Fri, 07 Nov 1997 09:46:24 -0500
From: David Corcoran <corcordt@cs.purdue.edu>
Subject: Perl variable filehandles
Message-Id: <346329BF.332E@cs.purdue.edu>
I'm trying to write a sockets module for a specific job at work
and was curious if someone knew how to create a variable FileHandle.
Currently I have a
$remote = accept(TMP,SOCK);
$users[$i++] = */TMP;
I would like to be able to select that handle to print to
such as a print {$users[$i++]} "Welcome to port xxx.\n";
Does anyone know how to go about this ????
Thanks
Dave
------------------------------
Date: Fri, 7 Nov 1997 13:38:29 GMT
From: jamesgry@netcom.com (James Gryga)
Subject: Print output contains extra characters
Message-Id: <jamesgryEJA385.79M@netcom.com>
I have written a short perl script that opens three files. In each of
the files is a list of words. This is just a plain list as in the examle:
apple
boy
marble
pens
I wanted perl to select one word at random from each of the three lists
and print them. When I orginally wrote this using Perl5 for win95 it
worked OK except that the output looked like
You "boy", "car", "tractor",
This is just an example and the the actual word list. But the output is
what you saw on the screen. I wanted it to look like
You boy car tractor.
That was my original problem. This morning I moved the perl script to
the linux side of my machine this one is running version 4 of perl for
linux. However, I was basing my scripts on the old Camel and Llama books
which were for version 4 anyway.
Anyway, under linux, I get completely random results. Sometimes only one
word is displayed, sometimes two, but there is no space between words.
The script below is the one that from my linux side.
Any help or pointers would be greatly appreciated.
jim
Script:
#!/usr/bin/perl
srand();
&part_1;
sub part_1 {
open(WORDS1, "/home/jamesgry/ws001.txt") || die "Can't open the file 1\n";
while (@WordList01 = <WORDS1>) {
chop(@WordList01);
$WordTotals01 = @WordList01;
$ItemNumber01 = int(rand($WordTotals01));
$OutPut01 = $WordList01[$ItemNumber01];
}
close(WORDS1);
&part_2;
}
sub part_2 {
open(WORDS2, "/home/jamesgry/ws002.txt") || die "Can't open the file 2\n";
while (@WordList02 = <WORDS2>) {
chop(@WordList02);
$WordTotals02 = @WordList02;
$ItemNumber02 = int(rand($WordTotals02));
$OutPut02 = $WordList02[$ItemNumber02];
}
close(WORDS2);
&part_3;
}
sub part_3 {
open(WORDS3, "/home/jamesgry/ws003.txt") || die "Can't open the file 3\n";
while (@WordList03 = <WORDS3>) {
chop(@WordList03);
$WordTotals03 = @WordList03;
$ItemNumber03 = int(rand($WordTotals03));
$OutPut03 = $WordList03[$ItemNumber03];
}
close(WORDS3);
}
print "Thou $OutPut01 $OutPut02 $OutPut03\n";
------------------------------
Date: 7 Nov 1997 11:01:09 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: Protecting Perl Source
Message-Id: <63usdl$htu$1@pheidippides.axion.bt.co.uk>
Randy Ford (randy@null.net) wrote:
: Michael A. Suarez wrote:
: >
: > What is a good way to protect perl source... I want to give some perl
: > programs to a client, but I need to keep them from being modified,
: > edited, etc. I want to distribute them more as binaries, but compiling
: > them is not allowed. Any ideas?
: >
: > Michael
: On CPAN the other day, I saw a module that would encrypt a script, and
: dynamical unencrypt it when it ran. I don't remember which one: I didn't
: need it; I just thought that it sounded neat.
You want
$CPAN/modules/by-module/Filter/Filter-1.12.tar.gz
Paul
------------------------------
Date: Fri, 07 Nov 1997 18:47:57 +0800
From: Mike Wang <wangyj@sro.cig.mcel.mot.com>
Subject: semaphore in perl
Message-Id: <3462F1DD.113DB901@sro.cig.mcel.mot.com>
I found there are three fuctions "semget,semop,semctl" in perl, but I
failed to make them work properly. The case is that I write a perl
program, which might be run and update a unique file at the same time.
So I want to use "semaphore" for balance. Could you please give me an
example code? Please give me an email directly if you don't mind.
Thanks in advance.
------------------------------
Date: 7 Nov 1997 11:36:52 GMT
From: Morten Simonsen <mortensi@idt.ntnu.no>
Subject: Re: semaphore in perl
Message-Id: <63uugk$8t5$1@due.unit.no>
Mike Wang <wangyj@sro.cig.mcel.mot.com> wrote:
: I found there are three fuctions "semget,semop,semctl" in perl, but I
: failed to make them work properly. The case is that I write a perl
: program, which might be run and update a unique file at the same time.
: So I want to use "semaphore" for balance. Could you please give me an
: example code? Please give me an email directly if you don't mind.
: Thanks in advance.
Here is some tested example code: (from some book)
package Semaphore;
sub create {
local ($IPC_KEY) = @_;
local ($semid);
$IPC_CREATE = 0001000;
$semid = semget($IPC_KEY,1,0666|$IPC_CREATE);
die "Semaphor-smget failed" if !defined($semid);
$semnum = 0;
$semflag = 0;
$opstring = pack("sss", $semnum, $semop = 1, $semflag);
semop($semid,$opstring) || die "$!";
return $semid;
}
sub take {
local ($IPC_KEY) = @_;
local ($semid);
$semid = semget($IPC_KEY,0,0);
die if !defined($semid);
$semnum = 0;
$semflag = 0;
$opstring = pack("sss", $semnum, $semop = -1, $semflag);
semop($semid,$opstring) || die "$!";
}
sub give {
local($IPC_KEY) = @_;
local($semid);
$semid = semget($IPC_KEY,0,0);
die if !defined($semid);
$semnum = 0;
$semflag = 0;
$opstring = pack("sss",$semnum,$semop = 1, $semflag);
semop($semid,$opstring) || die "$!";
}
1;
------------------------------
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 1285
**************************************