[7597] in Perl-Users-Digest
Perl-Users Digest, Issue: 1223 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 24 08:12:34 1997
Date: Fri, 24 Oct 97 05:00:41 -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 Fri, 24 Oct 1997 Volume: 8 Number: 1223
Today's topics:
^<<<<<<<<<<<~~ with \n <arollins@pamd.cig.mot.com>
Re: BUG? parenthesis problem in regex <caplain@znet.com>
Re: Hashed ref. to filehandle generates a warning (?) <caplain@znet.com>
Re: Hashed ref. to filehandle generates a warning (?) (Mike Stok)
Help Needed with NT Perl on Alpha (Marcus S Leef)
Help with Perl and Service Pack 3 from Microsoft to Win <supernet@mail.telepac.pt>
HELP: Registration with .htaccess ???? <tkonink@horizon.nl>
Re: HELP: Registration with .htaccess ???? (Mike Stok)
Re: How to go a particular line in a file? (Nem W Schlecht)
How to recoginze "-I" option in perl script <higashi@cadence.com>
Re: How to recoginze "-I" option in perl script (Tad McClellan)
padding digits... plambert$1@plambert.org
Re: padding digits... <eike.grote@theo.phy.uni-bayreuth.de>
Re: Primes via regexen (Was: Re: non-greedy regexps) (Abigail)
Re: Primes via regexen (Was: Re: non-greedy regexps) (Ilya Zakharevich)
replacing quotes with help of a regexp? (Calle ]sman)
Re: replacing quotes with help of a regexp? (Tad McClellan)
Running a Script at Startup <jrcruto@bechtel.com>
Skipping first n chars in a stream <email.in.sig@nvg.ntnu.no>
syslog <danny@dts-s.de>
the disappearing label problem... <kjell.myksvoll@fou.telenor.no>
Using .forward file to trigger Perl script <fp@pmpcs.com>
Win32 Perl return code missing <bmohn@wln.com>
Re: Year 2000 for GNU-Perl5 (John Moreno)
Re: Year 2000 for GNU-Perl5 <seay@absyss.fr>
Year2000 problem with localtime(); <pmeigh01@cork.cig.mot.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 23 Oct 1997 15:29:21 -0500
From: Andy Rollins <arollins@pamd.cig.mot.com>
Subject: ^<<<<<<<<<<<~~ with \n
Message-Id: <344FB3A1.C6523195@pamd.cig.mot.com>
Hi all!
I found a reference in dejanews to an article similar to this posted last year.
In the article, the poster wondered whether FORMAT was converting newlines (\n)
to spaces, and printing them as spaces. Did an answer ever show up for this
question? I have run into a similar situation, where I would like newlines to
be active in a picture line. Any suggestions? Thanks in advance!
Andy
--
Andrew N. Rollins, Ph.D. Systems Engineer
Motorola arollins@pamd.cig.mot.com
------------------------------
Date: Thu, 23 Oct 1997 22:17:32 -0800
From: Eric Caplain <caplain@znet.com>
Subject: Re: BUG? parenthesis problem in regex
Message-Id: <34503D7C.385@znet.com>
The way I avoid having to deal with parentheses causing problems with
a regex is to always convert them to something else before doing any
processing.
e.g. for your example I'd do this:
$var =~ s/\(/&lparen;/g;
$var =~ s/\)/&rparen;/g;
Or do it for $description - whatever makes sense.
--
caplain@znet.com
http://sf.znet.com/~caplain
------------------------------
Date: Thu, 23 Oct 1997 21:58:41 -0800
From: Eric Caplain <caplain@znet.com>
Subject: Re: Hashed ref. to filehandle generates a warning (?)
Message-Id: <34503911.81F@znet.com>
I don't have an answer as to why perl complains, but in case
it's of use, you can do the same thing this way without complaint:
open (TEST, ">myfile.txt");
$HandleList{$first} = "TEST";
$handle = $HandleList{$first}
print $handle "Howdy\n";
--
caplain@znet.com
http://sf.znet.com/~caplain
------------------------------
Date: 24 Oct 1997 10:57:59 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Hashed ref. to filehandle generates a warning (?)
Message-Id: <62puvn$28t@news-central.tiac.net>
In article <62ovrq$l0b$1@news2.voicenet.com>, <nospam@domain.com> wrote:
>
>This code:
>
>open (TEST, ">myfile.txt");
>$HandleList{$first} = \*TEST;
>print ${ $HandleList{$first} } "Howdy\n";
>So is it wrong, or right? What's the right way?
>If this is the only way to do it, then why does it
>generate an error? I think I'm misunderstanding
>something.
You can use a simple scalar or a block in that slot, as well as a
filehandle, so you can say
print {$HandleList{$first}} "Howdy\n";
or use an intermediate scalar variable
$fh = $HandleList{$first};
print $fh "Howdy\n";
This is covered in the FAQ page at
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlfaq5/How_can_I_make_a_filehandle_loca.html
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: 24 Oct 1997 04:40:28 GMT
From: mleef@blue.seas.upenn.edu (Marcus S Leef)
Subject: Help Needed with NT Perl on Alpha
Message-Id: <62p8rs$3mu$2@netnews.upenn.edu>
I am trying to track down PERL for NT on Alpha .. has anyone seen this?
Please email all responses.
Marcus
mleef@seas.upenn.edu
------------------------------
Date: 24 Oct 1997 11:39:43 GMT
From: "Nunes" <supernet@mail.telepac.pt>
Subject: Help with Perl and Service Pack 3 from Microsoft to WinNT 4.0
Message-Id: <01bce069$ad0f9a00$2ec641c2@host.telepac.pt>
Hi,
I need some help with the latest Service Pack 3 for WinNT 4.0.
I've WinNT 4.0 and IIS 3.0 and also Perlwin32 to run some scripts. I've
instaled Service Pack 3 and when I try to run some of my scripts they don't
work because the environment variable PATH_TRANSLATED (Maps the script's
virtual path to the physical path used to call the script) is not returning
the same value. This happen after I've installed SP3.
What I have to do to correct this situation ?
If you know the answer please email me to supernet@mail.telepac.pt
Thank's
Pedro
------------------------------
Date: Thu, 23 Oct 1997 21:44:37 +0100
From: "T. de Konink" <tkonink@horizon.nl>
Subject: HELP: Registration with .htaccess ????
Message-Id: <344FB734.7730DDB3@horizon.nl>
Hi,
I hope you can help me.
I want to set up a member-only zone, with pages and scripts only for
members. A person entering this zone has to log in.
The problems I face are:
- If someone has logged in (.htacces or ????) and starts a script within
the zone (of scripts and pages), can I identify (within a Perl-script)
the person by getting his Loginname somehow.
Questions:
- Is this possible ?
- Can it be done using Perl scripts ?
- Or must I use something like JavaScript and/or Cookies ?
Other question:
- Can I use Cookies (getting/sending/deleting) within Perl-scripts ?
My English isn't good, but I hoop it's understandable. Sorry for the
fact, I placed this message in different groups, but I don't know
exactly where I've to post this question.
Thanks in advance.
--
Thomas de Konink
mailto:tkonink@horizon.nl
------------------------------
Date: 24 Oct 1997 10:49:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: HELP: Registration with .htaccess ????
Message-Id: <62pug4$22f@news-central.tiac.net>
In article <344FB734.7730DDB3@horizon.nl>,
T. de Konink <tkonink@horizon.nl> wrote:
>I want to set up a member-only zone, with pages and scripts only for
>members. A person entering this zone has to log in.
>The problems I face are:
>- If someone has logged in (.htacces or ????) and starts a script within
>the zone (of scripts and pages), can I identify (within a Perl-script)
>the person by getting his Loginname somehow.
>
>Questions:
>- Is this possible ?
>- Can it be done using Perl scripts ?
>- Or must I use something like JavaScript and/or Cookies ?
>
>Other question:
>- Can I use Cookies (getting/sending/deleting) within Perl-scripts ?
Most of the answers depend of your web server's set up. Usually a CGI
script which is running in an area which requires access will set up an
environment variable which you can get at as $ENV{'REMOTE_USER'} in perl.
Note that the script must be in the protected area to get the user name in
the environment.
As mentioned in Tom Christiansen's "The Idiot's Guide to Solving Perl CGI
Problems" at
http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html
amongst other places, there is a perl5 module (now distributed with the
core distribution) CGI.pm which is probably the best thing to use for CGI
scripting in perl and has facilities for checking & using cookies.
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: 23 Oct 1997 21:32:34 -0500
From: nem@abattoir.cc.ndsu.nodak.edu (Nem W Schlecht)
Subject: Re: How to go a particular line in a file?
Message-Id: <62p1c2$ffb@abattoir.cc.ndsu.nodak.edu>
[courtesy copy e-mailed to author(s)]
In comp.lang.perl.misc, Fritz Knack <fritz.knack@POPULUS.net> wrote:
>On 22 Oct 1997 20:47:09 GMT, cberry@cinenet.net (Craig Berry) wrote:
>
>>John Robson (as646@FreeNet.Carleton.CA) wrote:
>>:
>>: The special variable $. automatically keeps track of the line read and
>>: increments itself.
>>: But it doesn't allow you to modify it, to assign a value to it (?!).
>>:
>>: Suppose I open a file and want to jump directly to, for example, line 8, how
>>: do I do this ? Doing $. =+ 7 doesn't seem to work.
>>
>> while (<FILE>) {
>> last if $. == 8;
>> }
>
>If he needed to use the same file again (say, for line 6), would a new
>while (<FILE>) automatically reset the $. variable? In ohter words,
>would the following hit the "oops" or execute the "line 6 thing"
>below?
Hmm.. here's how the file stuff works. There is a 'pointer' pointing to
current spot in a file. It is reset only when the filehandle is closed or
there is a seek() call telling it to go somewhere else. So, if, after the
above, he needed line 6, he would have to do this:
$. = 0;
seek(FILE,0,0);
while (<FILE>) {
last if $. == 6;
}
Obviously, if you need both, it's better to grab six when you go by it the
first time! ;-)
>If it doesn't automatically reset the counter, how do you make it do
>so? Close/Reopen?
See above (first 2 lines of code that I give).
--
Nem W Schlecht nem@plains.nodak.edu
NDUS UNIX SysAdmin http://www.nodak.edu/~nem
"Perl did the magic. I just waved the wand."
------------------------------
Date: Thu, 23 Oct 1997 15:08:51 +0900
From: Kiyohiro Higashijima <higashi@cadence.com>
Subject: How to recoginze "-I" option in perl script
Message-Id: <344EE9F2.6A45F349@cadence.com>
Hi All.
I am trying to recognize a library path for reading my subroutines.
the following is sample of perl script.
-----File:test--------------
#!/usr/local/bin/perl -d -I/modver/catalogVCD/local/lib/perl5
require 'stat.pl';
print "hello\n"
------------------------
and I invoke the above from unix prompt.
unix > test
Unrecognized switch: - -I/modver/.
perl does not recognize "-I" option for adding a search path for read
packages .
If anyone know how to solve my error, Please let me know.
Thanks
higashi
------------------------------
Date: Fri, 24 Oct 1997 06:24:04 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to recoginze "-I" option in perl script
Message-Id: <kg0q26.ij.ln@localhost>
Kiyohiro Higashijima (higashi@cadence.com) wrote:
: I am trying to recognize a library path for reading my subroutines.
: the following is sample of perl script.
: -----File:test--------------
: #!/usr/local/bin/perl -d -I/modver/catalogVCD/local/lib/perl5
: require 'stat.pl';
: print "hello\n"
: ------------------------
: and I invoke the above from unix prompt.
: unix > test
: Unrecognized switch: - -I/modver/.
#!/usr/local/bin/perl -dI/modver/catalogVCD/local/lib/perl5
Some systems limit the above line to a maximum of 32 characters...
: perl does not recognize "-I" option for adding a search path for read
: packages .
: If anyone know how to solve my error, Please let me know.
#!/usr/local/bin/perl -d
use lib '/modver/catalogVCD/local/lib/perl5';
require 'stat.pl';
print "hello\n"
OR
#!/usr/local/bin/perl -d
require '/modver/catalogVCD/local/lib/perl5/stat.pl';
print "hello\n"
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 24 Oct 1997 05:38:10 GMT
From: plambert$1@plambert.org
Subject: padding digits...
Message-Id: <62pc82$2lb$1@nntp1.ba.best.com>
OK, I'm trying to write a sorting routine to do some fancy stuff with
numbers. To make it work the way I'd like it to, I need a simple (and
_fast_) way to pad strings of digits in an existing string.
i.e. a string "foo 72 is a 35000000 element array" should be padded like
this:
print &padstring(10, "foo 72 is a 35000000 element array");
foo 0000000072 is a 0035000000 element array
and hence, a comparison with:
&padstring(10, "item 3") cmp &padstring(10, "item 11")
would give -1, since "item 0000000003" is less than "item 0000000011".
the ideal would be a way of quickly determining the longest digit-series
length in the comparison function. however, that's another bridge for
another day. ;-)
any suggestions would be welcome. please, if possible, cc me on any
followups.
thanks!
--paul lambert
------------------------------
Date: Fri, 24 Oct 1997 10:39:50 +0200
From: Eike Grote <eike.grote@theo.phy.uni-bayreuth.de>
Subject: Re: padding digits...
Message-Id: <34505ED6.794B@theo.phy.uni-bayreuth.de>
Hi,
plambert$1@plambert.org wrote:
>
> OK, I'm trying to write a sorting routine to do some fancy stuff with
> numbers. To make it work the way I'd like it to, I need a simple (and
> _fast_) way to pad strings of digits in an existing string.
>
> i.e. a string "foo 72 is a 35000000 element array" should be padded like
> this:
>
> print &padstring(10, "foo 72 is a 35000000 element array");
>
> foo 0000000072 is a 0035000000 element array
You could use a subroutine like this (in fact, it's just a regular
expression making use of the features of 'sprintf'):
sub padstring {
my ($z,$t) = @_;
$t =~ s/\d+/sprintf "%0${z}d",$&/eg;
return $t;
}
>
> and hence, a comparison with:
>
> &padstring(10, "item 3") cmp &padstring(10, "item 11")
Why not simply say
&extract_number("item 3") <=> &extract_number("item 10")
with &extract_number based on
($number) = ( $string =~ /(\d+)/ );
>
> would give -1, since "item 0000000003" is less than "item 0000000011".
>
> the ideal would be a way of quickly determining the longest digit-series
> length in the comparison function. however, that's another bridge for
> another day. ;-)
>
> any suggestions would be welcome. please, if possible, cc me on any
> followups.
[done]
Bye, Eike
--
=======================================================================
>>--->> Eike Grote <eike.grote@theo.phy.uni-bayreuth.de> <<---<<
-----------------------------------------------------------------------
Home Page, Address, PGP,...: http://www.phy.uni-bayreuth.de/~btpa25/
-----------------------------------------------------------------------
PGP fingerprint: 1F F4 AB CF 1B 5F 4B 1D 75 A1 F9 C5 7B 3F 37 06
=======================================================================
------------------------------
Date: 24 Oct 1997 04:56:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Primes via regexen (Was: Re: non-greedy regexps)
Message-Id: <slrn650ao9.qp.abigail@betelgeuse.wayne.fnx.com>
Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on 1514 September 1993
in <URL: news:62onnq$2dj$1@agate.berkeley.edu>:
++ In article <62o2u6$24a@gateway.grumman.com>,
++ John L. Allen <allen@gateway.grumman.com> wrote:
++ > In article <slrn64sgsv.qp.abigail@betelgeuse.wayne.fnx.com>,
++ > Abigail <abigail@fnx.com> wrote:
++ >
++ > >perl -wle 'print "Prime" if (1 x shift) =~ /^(?!(11+)\1+$)/'
++ >
++ > Cooool.
++ >
++ > exec >/dev/null
++ >
++ > N=$1
++ >
++ > time perl -le '$N = shift; while ($_.=1, $n++<$N) {
++ > print $n if /^(?!(11+)\1+$)/ }' $N
++ >
++ > time perl -le '$N = shift; while ($_.=1, $n++<$N) {
++ > print $n if !/^(11+?)\1+$/ }' $N
++ >
++ > For N=3000, I got real times of
++ >
++ > 1m36.93s
++ > 0m43.57s
++
++ This is very strange. There should be no substantial difference in
++ time due to (?!), and I would think that 1+? should be slower for
++ failing matches, when + and +? are semantically equivalent.
++
++ Since 7/8 matches fail, one should not observe any real difference.
No. 7/8 matches *don't* fail. What you are looking for whether the
string has composite length, the regex engine stops looking as soon
as it finds a possibility. By using (11+?), a matching length for
\1 is found the first step in 50% of the cases - all even numbers.
By using (11+), you'd need at least n/2 tries before finding
a matching length. Hence the difference.
More seriously, discussion on IRC revealed a bug in the regex engine:
perl -wle 'print length ($1) if (1 x shift) =~ /^(11+?)\1+$/' 100090
gives 5, where it should give 2. Apparently, + doesn't match more
than 32768 times.
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^(11+?)\1+$/'
------------------------------
Date: 24 Oct 1997 06:25:40 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Primes via regexen (Was: Re: non-greedy regexps)
Message-Id: <62pf15$jhk$1@agate.berkeley.edu>
In article <slrn650ao9.qp.abigail@betelgeuse.wayne.fnx.com>,
Abigail <abigail@fnx.com> wrote:
> ++ Since 7/8 matches fail, one should not observe any real difference.
>
> No. 7/8 matches *don't* fail.
Thanks, that is right.
> More seriously, discussion on IRC revealed a bug in the regex engine:
>
> perl -wle 'print length ($1) if (1 x shift) =~ /^(11+?)\1+$/' 100090
>
> gives 5, where it should give 2. Apparently, + doesn't match more
> than 32768 times.
This is a feature. Though the particular case *might* be fixed after
jumbo patch. Do not think anybody would bother.
Ilya
------------------------------
Date: 24 Oct 1997 12:26:25 +0200
From: md4calle@mdstud.chalmers.se (Calle ]sman)
Subject: replacing quotes with help of a regexp?
Message-Id: <w7pzpnz319q.fsf@fraggel55.mdstud.chalmers.se>
I want to search and replace some blocks of text. The blocks of text contains
a bunch of <>".?
I thought it would do by using '' around the text like:
$lines[$cnt++] =~ s/'src="pics/sm_feed2.gif" vspace=2><br>'/a/g;
well, it complains, quite loudly, about this. What Am I doing wrong?
--
/Calle
**************************************************************************
* * My homepage about the author Tom Holt: *
* /_\ http://www.mdstud.chalmers.se/~md4calle/holt/ *
* { ~._.~ } *
* ( Y ) other things like OnLine Guitar Archive linkpage *
* ( )~*~( ) and heaps of musiclinks can be found at *
* (__)-(__) http://www.mdstud.chalmers.se/~md4calle/ *
**************************************************************************
------------------------------
Date: Fri, 24 Oct 1997 06:37:58 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: replacing quotes with help of a regexp?
Message-Id: <ma1q26.8l.ln@localhost>
Calle ]sman (md4calle@mdstud.chalmers.se) wrote:
: I want to search and replace some blocks of text. The blocks of text contains
: a bunch of <>".?
No problem.
: I thought it would do by using '' around the text like:
Problem ;-)
: $lines[$cnt++] =~ s/'src="pics/sm_feed2.gif" vspace=2><br>'/a/g;
: well, it complains, quite loudly, about this. What Am I doing wrong?
1) < and > are not special in regexs. Just use them as you would
any other non-special character
2) single quotes are also not special, so they match themselves.
ie. the above will only match if there are single quotes at
the appropriate place in the string that you are matching against.
3) This is the real problem:
$lines[$cnt++] =~ s/'src="pics/sm_feed2.gif" vspace=2><br>'/a/g;
^ ^ ^
^ end of regex
If your pattern uses the character that you have chosen for the
regex delimiter, then you need to either
1) escape the char:
$lines[$cnt++] =~ s/'src="pics\/sm_feed2.gif" vspace=2><br>'/a/g;
^
2) use a different regex delimiter:
$lines[$cnt++] =~ s#'src="pics/sm_feed2.gif" vspace=2><br>'#a#g;
^ ^ ^
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 24 Oct 1997 09:21:11 GMT
From: "Jay Cruto" <jrcruto@bechtel.com>
Subject: Running a Script at Startup
Message-Id: <01bcdde4$1b727860$82100193@sinw0313.bechtel.com>
How do I execute a Perl script automatically when a page is initially
loaded?
Can anyone show me please?
Thanks.
------------------------------
Date: 24 Oct 1997 06:48:33 GMT
From: Salve J Nilsen <email.in.sig@nvg.ntnu.no>
Subject: Skipping first n chars in a stream
Message-Id: <62pgc1$dar$1@due.unit.no>
Hello everybody...
A Mediocre Problem:
I'd like to make a small perl-script that reads a stream of characters
for STDIN, skips the n first, and then writes the rest unbuffered to
STDOUT - preferably one character at a time.
This is what I tried (skipping the first 23 chars):
perl -e '$|=1; read(STDIN,$_,23); print STDOUT <STDIN>'
perl -e '$|=1; read(STDIN,$_,23); print STDOUT while($_=<STDIN>)'
perl -e '$|=1; read(STDIN,$_,23); print STDOUT while($_=getc)'
I've also tried fiddling around with $/, $\ and select(), but with no
result.. :/
Could someone please help? :)
Thanks.
- Salve Nilsen
--
#!/usr/local/bin/perl
$_ = 'Sometimes I have dreams, dreams where I wish my email address was
president@whitehouse.gov
but, alas - it is only...'; s/.*?ent/sjn/s; s/whi.*/pvv.org\n/s; print;
------------------------------
Date: Fri, 24 Oct 1997 13:27:45 +0200
From: "Daniel T. Schwager" <danny@dts-s.de>
Subject: syslog
Message-Id: <34508631.C3ACDD0A@dts-s.de>
Hallo together,
i'm not able to write a log-message via the syslog-module.
(Linux 2.0.30, SuSE 5.0). I tried to install perl5.004_01, but
the result was the same: nothing:
Here is my test-script (man Ssy::Syslog):
----------------------------------------
#!/usr/bin/perl
use Sys::Syslog;
$program="mytestprg";
print $program;
openlog($program, 'cons,pid', 'user');
syslog('mail|warning', 'this is a better test: %d', time);
closelog();
-------------------------------------------
Is it also possible to email the reply ?
regards from the cold Stuttgart / Germany
Danny
------------------------------
Date: 24 Oct 1997 11:05:14 +0200
From: Kjell Myksvoll TFR <kjell.myksvoll@fou.telenor.no>
Subject: the disappearing label problem...
Message-Id: <ujtk9f3il9x.fsf@vargtass.nta.no>
Hello,
I've got the following test program:
#! /bin/perl -w
$timeout = 1;
# handle timeout event
sub timeout_handler {
print " interupted after ", $timeout, " (sec).\n";
$timeout += 1;
redo TRY;
}
$SIG{'ALRM'} = 'timeout_handler';
## main
TRY: {
print "working...\n";
alarm $timeout; # timeout after <n> sec.
$i = 0;
while (1) { $i++; }
alarm 0; # cancel
}
When running it with perl v.4 it behaves as expected, ie. the while
loop gets interrupted by a alarm signal after $timeout seconds and
thereafter resumed by the redo jump to the TRY label.
Not so under Perl v. 5. From the debugger I got the following
diagnostic:
Label not found for "redo TRY" at ./label.pl line 9, <IN> chunk 34.
That is that the TRY label is somehow gone.
This problem is probably the one that is described in point 11 in the
"Perl v. 4 to v. 5 traps"(?) document (available at www.perl.com).
Fair enough, but is there some way to rewrite the code so that it
works both in v. 4 and v. 5 of Perl? (I find it useful to timeout
external commands that is executed by the system call.)
best regards,
kmm
------------------------------
Date: 24 Oct 97 11:44:15 GMT
From: "Peter Perchansky" <fp@pmpcs.com>
Subject: Using .forward file to trigger Perl script
Message-Id: <01bce072$25436a80$79592581@pmp>
Greetings:
Where may I find more information on utilizing the ".forward" file
(specially in Apache 1.2) to trigger the execution of a Perl script?
Goal... incoming email triggers Perl script that handles the email
based on either the "to", "cc" and "bcc" lines.
Thank you for your time.
P.S. Please email me a copy of your reply. I do frequent this news
group, but often find > 100 messages when I come back... and sifting
through the messages to find replies can be fun ;-)
--
===========================================================
Peter Perchansky, Computer Consultant & Microsoft FrontPage MVP
PMP Computer Solutions
FrontPage Web Hosting at
http://www.pmpcs.com/services/fpwebhosting.htm
FrontPage Support http://www.pmpcs.com/support/frontpage.htm
------------------------------
Date: Thu, 23 Oct 1997 22:39:50 -0700
From: Bill Mohn <bmohn@wln.com>
Subject: Win32 Perl return code missing
Message-Id: <345034A6.73F1218@wln.com>
I'm having trouble making Perl on Win95 work the way I think it should.
It performs correctly on Unix and NT. The problem relates to getting
return codes back from external commands that are invoked. My
understanding is that if I invoke a command with system() or with
backticks, $? should be set to the exit status of the external command.
I get the following results on Win95:
$rc=system("failing_cmnd"); # returns a proper return code and output
goes to the terminal.
$rc=system("failing_cmd >outfile"); #sets $rc and $? to zero and puts
stdout in outfile.
$output=`failing_cmd`; #sets $? to zero and puts the output in $output.
Techniques like open (TMP, "failing_cmd >"); don't give a return code
until the asynchronous command ends.
In other words, if I want a true final exit code AND I want the
stdout/stderr from the command I can't seem
to get both. As I said, all forms work as I'd expect on NT and UNIX.
I'm running the Activeware Win32 Perl Build 310. I suspect it has
something to do with cmd32.exe but
I can't figure it out. Seems like it's an obvious bug that would have
been fixed so I must be doing something
wrong.
Bill Mohn
------------------------------
Date: Fri, 24 Oct 1997 00:42:41 -0400
From: phenix@interpath.com (John Moreno)
Subject: Re: Year 2000 for GNU-Perl5
Message-Id: <199710240037341618800N@roxboro-186.interpath.net>
Jeremy D. Zawodny <zawodny@hou.moc.com> wrote:
] [cc'd automagically to original author]
]
] Michael P Chandler <mpchandler@mema.mail.fedex.com> wrote:
]
] > Is there a site/page/etc where I can find out if Perl5 (gnu
] > version), or Perl5 in general, is Year 2000 compliant???
] >
] > I understand many considerations are hardware/OS dependent,
] > but I'm concerned about getting any patches/fixes if need-be.
]
] Unfortunately, searching http://www.perl.com/ for '2000' or '1900' or
] 'compliant' doesn't turn up much. :-(
]
] However, if you code properly, your programs will not break. The only
] gotcha in Perl is that many of the time/date functions return the
] century - 1900. Simply adding 1900 yields a 4-digit date.
What time/date functions are that? I'm only aware of $^T and time - and
I believe that they number it returns is platform dependent. On the Mac
it is the number of seconds since 01/01/1904.
] Note the difference between that and having it roll to '00' at the
] year 2000. Perl will see it as 100.
Yep. Just add 1900.
--
John Moreno
------------------------------
Date: Fri, 24 Oct 1997 12:28:51 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Year 2000 for GNU-Perl5
Message-Id: <34507863.D6C5BF1@absyss.fr>
John Moreno wrote:
>
> Jeremy D. Zawodny <zawodny@hou.moc.com> wrote:
> ] However, if you code properly, your programs will not break. The only
> ] gotcha in Perl is that many of the time/date functions return the
> ] century - 1900. Simply adding 1900 yields a 4-digit date.
>
> What time/date functions are that? I'm only aware of $^T and time - and
> I believe that they number it returns is platform dependent. On the Mac
> it is the number of seconds since 01/01/1904.
localtime() and gmtime() return the year-1900. Here's the scoop on
localtime. It doesn't mention being Mac specific like time().
~> perldoc -f localtime
=item localtime EXPR
Converts a time as returned by the time function to a 9-element array
with the time analyzed for the local time zone. Typically used as
follows:
# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
All array elements are numeric, and come straight out of a struct tm.
In particular this means that $mon has the range 0..11 and $wday has
the range 0..6 with sunday as day 0. Also, $year is the number of
years since 1900, that is, $year is 123 in year 2023.
If EXPR is omitted, uses the current time (C<localtime(time)>).
In a scalar context, returns the ctime(3) value:
$now_string = localtime; # e.g., "Thu Oct 13 04:54:34 1994"
Also see the Time::Local module, and the strftime(3) and mktime(3)
function available via the POSIX module.
------------------------------
Date: Fri, 24 Oct 1997 11:54:36 +0100
From: Peter Meighan <pmeigh01@cork.cig.mot.com>
Subject: Year2000 problem with localtime();
Message-Id: <34507E6A.ECBCF296@cork.cig.mot.com>
Hi y'all,
Of the values returned by localtime, the $year value is coming out
as '97'. Is there a plan to change this to `1997`? It's something that
could cause *major* problems, don't you think?
--
*-------------------------------------------------------------*
* Peter Meighan |
* Motorola ECID | "Motorboats, unlike cars, will not
* Cork, Ireland. | talk back to David Hasselhoff."
*-------------------------------------------------------------*
------------------------------
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 1223
**************************************