[7964] in Perl-Users-Digest
Perl-Users Digest, Issue: 1589 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 6 14:07:54 1998
Date: Tue, 6 Jan 98 11:00:37 -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, 6 Jan 1998 Volume: 8 Number: 1589
Today's topics:
Re: "shift @array" question (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: Advanced Perl Programming book (Gabor)
anagramming in perl? (a CPAN question) <*@qz.to>
Arrgghhhhh! There must be a simple solution to this scr (James Robshaw)
Re: Arrgghhhhh! There must be a simple solution to this <ebohlman@netcom.com>
Re: Arrgghhhhh! There must be a simple solution to this <bowens@eastman.com>
Re: Can I create a Linked List in Perl <joseph@5sigma.com>
Re: Can I create a Linked List in Perl (Gabor)
Re: Form input perl program passing parameters to anoth <rootbeer@teleport.com>
Re: Help with passing parameters in URL's please <rootbeer@teleport.com>
how I can extract n character in x position on a string <claudio@crpweb.com>
Re: how I can extract n character in x position on a st <ebohlman@netcom.com>
How I can sign number thousands example: 10000 to 10.0 <claudio@crpweb.com>
Re: How I can sign number thousands example: 10000 to (David B. White)
How to mimic C's #include "global.pl" <moises@texas.net>
Re: I tired to modify.... <r.goeggel@atos-group.de>
invalid IO handle <buxx@buxx.com>
Re: Lexical scope and embedded subroutines. <r.goeggel@atos-group.de>
Re: Lexical scope and embedded subroutines. (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: Lexical scope and embedded subroutines. (M.J.T. Guy)
Re: Lexical scope and embedded subroutines. <rootbeer@teleport.com>
Looking for perl <moab@emirates.net.ae>
Re: Looking for perl (Michael J Gebis)
Re: Looking for perl (Jeremy D. Zawodny)
Lotus Notes <chris@starkimages.com>
Re: Pattern match causing runtime exception (Dave Wolfe)
Re: Perl & Win95 running a dos box (Rick Lim)
Re: Perl sort( ) Argument Passing Problem (M.J.T. Guy)
Re: perldsc q: complex data from file (M.J.T. Guy)
Querying info from other server (Phil Buckley)
Re: Review of CGI/Perl book (John M. Klassa)
Re: sending email (Net::SMTP).. problem (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: serious post about gmtime and year-1900 (was Re: Pe <Russell_Schulz@locutus.ofB.ORG>
Updating Perl 5.003 to 5.004 on Solaris 2.51 <keefner@kinetic.com>
Using perl to validate links nikkim@senate.leg.state.mn.us
WebMirror 1.0 corrupting jpg files <clark@s3i.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 06 Jan 98 11:54:25 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: "shift @array" question
Message-Id: <34b261f2$5$ofn$mr2ice@speaker>
In <Pine.GSO.3.95.980106022129.22281A-100000@mercury>, on 01/06/98 at 02:40
AM,
Jerry Lineberry <jerryl@connecti.com> said:
+-----
| been done better. For instance, at one point I have to use the shift command
| three times in a row. Can this be done with one command?
+--->8
`perldoc -f splice`
--
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)
------------------------------
Date: 6 Jan 1998 18:43:13 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Advanced Perl Programming book
Message-Id: <slrn6b4ude.8fd.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, Thomas Charron <twolf@sampo.creighton.edu> wrote :
# Definatly am enjoying it..
#
# Allen Choy wrote in message <349848E6.E0D54461@us.oracle.com>...
# >Hi.
# >
# >Does anyone have any opinions, good and bad, re: the Advanced Perl
# >Programming book?
# >I'm considering purchasing it, but don't know much about it.
# >
# >Thanks!
# >
# >Allen
# >
It's a worthwhile purchase. It's one of the books I don't regret
buying. Up there with 'K&R2' for C and 'Programming Perl' for Perl and
'Advanced Programming in the Unix Environment' for Unix and 'The
Design and Implementation of the 4.4 BSD Operating System' on the
design of Unix
gabor.
--
str->str_pok |= SP_FBM; /* deep magic */
s = (unsigned char*)(str->str_ptr); /* deeper magic */
-- Larry Wall in util.c from the perl source code
------------------------------
Date: 6 Jan 1998 18:19:06 GMT
From: Eli the Bearded <*@qz.to>
Subject: anagramming in perl? (a CPAN question)
Message-Id: <qz$9801061257@qz.little-neck.ny.us>
I've played with anagramming tools, done it in my head, and written
programs to do them. So when broswing CPAN I noticed:
Other Text:: modules (these should be under String:: but pre-date it)
...
Anagram adcf Anangram generator ASHER
I thought that would be a fun but it doesn't seem to be anywhere on
CPAN. Am I looking in the wrong place or do I have to contact Aaron
Sherman to get this? I think it would be very helpful if the pre-
requisite for getting anything listed beyond 'i'dea stage would be
to at least have a README stating where to get it.
Is this such a problem?
Elijah
------
finds many of the CPAN READMEs unhelpful
------------------------------
Date: Tue, 06 Jan 1998 17:57:19 GMT
From: james@NoSpamrobshaw.zynet.co.uk (James Robshaw)
Subject: Arrgghhhhh! There must be a simple solution to this script error
Message-Id: <68trcv$fj2$1@sol.zynet.net>
Can anyone please point me in the right direction.
I have a perl script that works fine until I try to edit this particular
line from=20
print NEWFILE " <body >\n";
into
print NEWFILE " <body bgcolor=3D"#B4BCCD" text=3D"#000000" =
link=3D"#000066"
vlink=3D"#990000">\n";
Is it the repetition of the "#" that causes the error?
Can I place a default character in front of the # to prevent the error?
The script doesn't actually generate an error code, I just get the =
default
Server Error 500.
I have tried a couple of things, but none have worked. I'm going potty,
especially as at the moment, I can only test the script on-line.
All suggestions gratefully received.
James.
james@NOSPAMrobshaw.zynet.co.uk
------------------------------
Date: Tue, 6 Jan 1998 18:40:32 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Arrgghhhhh! There must be a simple solution to this script error
Message-Id: <ebohlmanEMDL7K.73q@netcom.com>
James Robshaw <james@NoSpamrobshaw.zynet.co.uk> wrote:
: I have a perl script that works fine until I try to edit this particular
: line from
: print NEWFILE " <body >\n";
: into
: print NEWFILE " <body bgcolor="#B4BCCD" text="#000000" link="#000066"
: vlink="#990000">\n";
: Is it the repetition of the "#" that causes the error?
No, it's the fact that the quote marks before your # are closing the
quoted string you started.
Either put backslashes before all the quotes that aren't actually
delimiters of the string you're trying to print, use single quotes to
delimit the string (that will work for the line you showed, but won't
work in other places if you need to do variable interpolation), or use
the qq mechanism with a delimiter that doesn't occur in the text.
------------------------------
Date: 6 Jan 1998 18:29:09 GMT
From: "Blaine Owens" <bowens@eastman.com>
Subject: Re: Arrgghhhhh! There must be a simple solution to this script error
Message-Id: <01bd1ad1$10f7bc40$13e288a8@PC83610221.kpt.emn.com>
I think it's getting confused by the double-qoutes. Remove them from the
bgcolor, etc. specifications (they really aren't necessary), or enclose the
entire string in single quotes.
--
Blaine Owens
bowens@eastman.com
James Robshaw <james@NoSpamrobshaw.zynet.co.uk> wrote in article
<68trcv$fj2$1@sol.zynet.net>...
Can anyone please point me in the right direction.
I have a perl script that works fine until I try to edit this particular
line from
print NEWFILE " <body >\n";
into
print NEWFILE " <body bgcolor="#B4BCCD" text="#000000" link="#000066"
vlink="#990000">\n";
Is it the repetition of the "#" that causes the error?
Can I place a default character in front of the # to prevent the error?
The script doesn't actually generate an error code, I just get the default
Server Error 500.
I have tried a couple of things, but none have worked. I'm going potty,
especially as at the moment, I can only test the script on-line.
All suggestions gratefully received.
James.
james@NOSPAMrobshaw.zynet.co.uk
----------
------------------------------
Date: Tue, 06 Jan 1998 11:21:51 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: Can I create a Linked List in Perl
Message-Id: <34B27634.A14D700C@5sigma.com>
There is almost no need to explicitly create linked lists in
Perl. You can do anything you want with array operators (including
splice).
-joseph
http://www.effectiveperl.com
draggs@hawkeye.idx.com wrote:
>
> I'm reasonably new to Perl, but am an old C programmer. I was
> wondering if it was possible to create a c-style linked list and perl.
> If it is, how would I go about doing so?
------------------------------
Date: 6 Jan 1998 18:36:49 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: Can I create a Linked List in Perl
Message-Id: <slrn6b4u1e.8fd.gabor@vinyl.quickweb.com>
In comp.lang.perl.misc, draggs@hawkeye.idx.com <draggs@hawkeye.idx.com> wrote :
# I'm reasonably new to Perl, but am an old C programmer. I was
# wondering if it was possible to create a c-style linked list and perl.
# If it is, how would I go about doing so?
#
Why would you want to? The reason for linked lists is generally
either for a stack or a queue. You can do both with lists in perl use
push,pop for a stack
and shift, push for a queue.
if you need to insert in the 'middle' use splice.
the element of a list can be anything, a scalar, a hash or another list.
gabor.
--
tmps_base = tmps_max; /* protect our mortal string */
-- Larry Wall in stab.c from the perl source code
------------------------------
Date: Tue, 6 Jan 1998 10:23:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Shulin Dave <shulin@wwave.com>
Subject: Re: Form input perl program passing parameters to another background precess?
Message-Id: <Pine.GSO.3.96.980106102225.7761H-100000@user2.teleport.com>
On Mon, 5 Jan 1998, Shulin Dave wrote:
> I have written state engine for an application in perl.
> Everytime there is a hit on the website it executes the whole script
> again. If I can get the input seperate & pass to the main state engine
> all the parameters that would reduce my memory usage as well as time.
Sounds as if you want Apache's mod_perl, which is made for just that
purpose.
> I was wondering is there any simple example which I should look for? I
> am not using modules.
You should start using modules. :-) 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: Tue, 6 Jan 1998 10:39:29 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: William Byrd <wcb4@erols.com>
Subject: Re: Help with passing parameters in URL's please
Message-Id: <Pine.GSO.3.96.980106103749.7761I-100000@user2.teleport.com>
On Tue, 6 Jan 1998, William Byrd wrote:
> I am guessing that because of Perl's UNIX heritage it cann;t cope with
> file names with spaces in it regardless of the underlying platform's
> filesystem, am I correct in this assumption?
No, spaces are valid in Unix file names, too. And if _that_ is the
problem, the solution is in the docs for the open() function. 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: Tue, 6 Jan 1998 18:22:09 +0100
From: "Claudio Villa Santa" <claudio@crpweb.com>
Subject: how I can extract n character in x position on a string?
Message-Id: <68tp7d$ili@news1.mclink.it>
Messaggio a piy sezioni in formato MIME.
------=_NextPart_000_0029_01BD1AD0.002B4F40
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all;
I have a little problem:
I need a function like visualbasic 'mid'.
I'll need to extract n character in x position on a string.
For example: "this is string" I need "str" n=3D3 x=3D8.
And how I can now number of string? (visualbasic function 'len')
Tanks
Claudio
------=_NextPart_000_0029_01BD1AD0.002B4F40
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#c8e0d8>
<DIV><FONT color=3D#000000 size=3D2>Hi all;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I have a little problem:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I need a function like visualbasic=20
'<STRONG>mid</STRONG>'.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I'll need to extract n character in x position on a=20
string.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>For example: "this is <U>str</U>ing" =
I need=20
"str" n=3D3 x=3D8.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>And how I can now number of string? (visualbasic =
function=20
'<STRONG>len</STRONG>')</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Tanks</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Claudio</FONT></DIV></BODY></HTML>
------=_NextPart_000_0029_01BD1AD0.002B4F40--
------------------------------
Date: Tue, 6 Jan 1998 18:36:14 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: how I can extract n character in x position on a string?
Message-Id: <ebohlmanEMDL0E.6uD@netcom.com>
Claudio Villa Santa <claudio@crpweb.com> wrote:
: I need a function like visualbasic 'mid'.
: I'll need to extract n character in x position on a string.
substr() does what you want.
: For example: "this is string" I need "str" n=3D3 x=3D8.
: And how I can now number of string? (visualbasic function 'len')
length() does what you want.
The perlfunc manpage tells you all you want to know, and more, about
Perl's built-in functions.
P.S. Please configure your newsreader so it doesn't send out a duplicated
HTML "formatted" copy of your posts.
------------------------------
Date: Tue, 6 Jan 1998 18:27:08 +0100
From: "Claudio Villa Santa" <claudio@crpweb.com>
Subject: How I can sign number thousands example: 10000 to 10.000
Message-Id: <68tpgf$iob@news1.mclink.it>
Messaggio a piy sezioni in formato MIME.
------=_NextPart_000_0034_01BD1AD0.B26DC520
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all;
=20
I have a little problem:
How I can sign number thousands example: 10000 to 10.000
=20
Tanks
=20
Claudio
------=_NextPart_000_0034_01BD1AD0.B26DC520
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.6"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#c8e0d8>
<DIV>
<DIV><FONT color=3D#000000 size=3D2>Hi all;</FONT></DIV>
<DIV><FONT color=3D#000000 size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>I have a little problem:</FONT></DIV>
<DIV><FONT face=3D"" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"" size=3D2>How I can sign number thousands example: =
10000 to=20
10.000</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=3D2>Tanks</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>Claudio</FONT></DIV></DIV></BODY></HTML>
------=_NextPart_000_0034_01BD1AD0.B26DC520--
------------------------------
Date: 6 Jan 1998 18:05:56 GMT
From: dbwhite@btv.vnet.ibm.com (David B. White)
Subject: Re: How I can sign number thousands example: 10000 to 10.000
Message-Id: <68trq4$1086$2@mdnews.btv.ibm.com>
In article <68tpgf$iob@news1.mclink.it>,
"Claudio Villa Santa" <claudio@crpweb.com> writes:
> How I can sign number thousands example: 10000 to 10.000
How about:
$formattedString = sprintf( "%.3f", $yourNumber / 1000 );
--
David B. White
IBM Microelectronics, Circuit Verification & Design Tools
Internal: dbwhite@btv Internet: dbwhite@vnet.ibm.com
Phone: 802-769-5671 (TieLine: 446) Fax: 802-769-5722
------------------------------
Date: Tue, 06 Jan 1998 12:50:11 +0000
From: "Moises G. Solis" <moises@texas.net>
Subject: How to mimic C's #include "global.pl"
Message-Id: <34B22882.13E3D709@texas.net>
I have a Perl script called global.pl that
contains global definitions. I want to bring
this script into another script. I'm trying to
mimic: #include "global.pl" from C. The question
is, which is the best way for doing this?
Thanks in advance,
Moises.
------------------------------
Date: Tue, 6 Jan 1998 16:50:24 +0100
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: I tired to modify....
Message-Id: <68tjui$dq6$1@news.pop-stuttgart.de>
Kriebel wrote <01bd1932$ca125460$6a7fabcc@ppp826278>...
<snip>
> print FILE "</a></tr><td></table><br><hr width="70%"><br>\n";
<snip a lot of }>
>is there anything wrong with that..or could it been possibly be the script
activate perl -w
look to the error messages
change to
print FILE "</a></tr><td></table><br><hr width=\"70%\"><br>\n";
HTH
------------------------------
Date: Tue, 06 Jan 1998 11:41:29 -0600
From: Buxx <buxx@buxx.com>
Subject: invalid IO handle
Message-Id: <34B26CC9.6CF6@buxx.com>
Upgraded to slakware k ver 2.0.29 and now my FTP module gives a
invalid IO handle when I try to execute in a previouly working
script. Module installation tests run find. Upgraded from
1.2.13 kernel
------------------------------
Date: Tue, 6 Jan 1998 16:38:22 +0100
From: "Ronald G\"oggel" <r.goeggel@atos-group.de>
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <68tj81$da9$1@news.pop-stuttgart.de>
Steve Goldstein wrote <34B11E43.167E@gcg.com>...
>The following script has a call to a subroutine within a subroutine.
>A "my" variable declared in the outer subroutine does not have the
>scope I had expected.
>
>#!/usr/local/bin/perl
to avoid a lot of errors you can use the flag "-w"
>
>foreach my $temp ( 'warm', 'cold')
Using the flag "-w" I got the error:
Variable "$param" will not stay shared at /r5/users/goeggel/perl/perl.test
line 26.
so I changed to
my $temp;
foreach $temp ('warm', 'cold')
>{
> What_is_the_temp($temp);
Here you'd better use
&What_is_the_temp($temp);
>}
>
>sub What_is_the_temp
>{
> my $param = shift;
> print "Outside it is $param.\n";
>
> embeddedsub();
Why didn't you pass the parameter to the subroutine?
Better use
&embeddedsub($param);
...
> return;
>
> sub embeddedsub
> {
... and retrieve it here via
my $param = shift;
> print " Inside it is always $param.\n";
> return;
> }
>}
>
>=============
>The output of the script is:
>
>Outside it is warm.
> Inside it is always warm.
>Outside it is cold.
> Inside it is always warm.
>=============
>
The output of the script is:
Outside it is warm.
Inside it is always warm.
Outside it is cold.
Inside it is always cold.
HTH
------------------------------
Date: Tue, 06 Jan 98 11:41:32 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <34b25fe8$4$ofn$mr2ice@speaker>
In <68sc4k$3p2$1@brokaw.wa.com>, on 01/05/98 at 08:33 PM,
"Aaron Harsh" <ajh@rtk.com> said:
+-----
| This behavior brings up the following questions:
| o Is Perl's behavior some sort of speed optimization?
| o Did the Perl gods just decide that scheme-like behavior was less
| important than the pseduo-static variables described in perlsub?
+--->8
I suspect you'll find that Perl's behavior is simply what falls out of
existing Perl semantics with anonymous in-line subroutines added
independently. It wasn't designed to have such behavior; it just *is*.
Whether it's what it *should be* is for the Perl Gods to answer, not me. I've
never been much more than a Perl Acolyte, even back in the Perl3 days. :-)
--
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)
------------------------------
Date: 6 Jan 1998 18:22:39 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <68tspf$9f0$1@lyra.csx.cam.ac.uk>
In article <68sc4k$3p2$1@brokaw.wa.com>, Aaron Harsh <ajh@rtk.com> wrote:
>
>Before I read this thread (and perlsub to get the details) I would have
>assumed the original code was fine.
>
>This behavior brings up the following questions:
> o Is Perl's behavior some sort of speed optimization?
No, but see below.
> o Did the Perl gods just decide that scheme-like behavior was less
>important than the pseduo-static variables described in perlsub?
This subject has been kicked about at some length on perl5-porters.
The current behaviour was chosen as the best of a bad job.
In the context of Perl, it's not obvious what "scheme-like behavior"
means. So it isn't an option. See below for details.
> o Does anyone else find Perl's behavior counter-intuitive?
*Everyone* finds it counterintuitive. The fact that it only generates
a warning rather than a hard error is part of the Perl Gods policy
of hurling thunderbolts at those so irreverent as not to use -w.
> o Did programming in scheme destroy my ability to judge a decent language
>feature?
You're still interested in Perl, so it can't have rotted your brain
completely.
> o Have I misremembered how scheme handles these situations?
Probably not.
> o Do Perl programmers really care how much Perl acts like scheme?
Some do.
> o Should I have stopped this message two or three questions ago?
Yes.
The problem to be solved can be stated as
"When a subroutine refers to a variable which is instantiated more than
once (i.e. the variable is declared in a for loop, or in a subroutine),
which instance of that variable should be used?"
The basic problem is that Perl isn't Scheme (or Pascal or any of the
other comparators that have been used).
In almost all lexically scoped languages (i.e. those in the Algol60
tradition), named subroutines are also lexically scoped. So the scope
of the subroutine is necessarily contained in the scope of any external
variable referred to inside the subroutine. So there's an obvious
answer to the "which instance?" problem.
But in Perl, named subroutines are globally scoped. (But in some
future Perl, you'll be able to write
my sub lex { ... }
to get lexical scoping.) So the solution adopted by other languages
can't be used.
The next suggestion most people come up with is "Why not use the most
recently instantiated variable?". This Does The Right Thing in many
cases, but fails when recursion or other complications are involved.
Consider
sub outer {
inner();
outer();
my $trouble;
inner();
sub inner { $trouble };
outer();
inner();
}
Which instance of $trouble is to be used for each call of inner()?
And why?
The consensus was that an incomplete solution was unacceptable, so
the simple rule "Use the first instance" was adopted instead.
And it is more efficient than possible alternative rules. But that's not
why it was done.
Mike Guy
------------------------------
Date: Tue, 6 Jan 1998 10:21:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: Lexical scope and embedded subroutines.
Message-Id: <Pine.GSO.3.96.980106100305.7761G-100000@user2.teleport.com>
On Mon, 5 Jan 1998, Larry D'Anna wrote:
> I believe that when perl comes across a function call to a undefined
> functionit finds the declaration later in the file and then calls the
> function.
I'm not sure what you mean by that; you may be right, or maybe not. :-)
At compile time, when the compiler comes across a subroutine call whose
name hasn't yet been seen by the compiler, it's compiled without a
problem. (Exception: A bareword won't be interpreted as a call to an
unknown sub, and will be an error under "use strict 'subs'".)
Later, at runtime, perl looks for the sub name in the symbol table; if it
still hasn't been defined by that time, then you have an error. This
allows you to define a new function at runtime. (Or, for that matter, to
redefine an old one.)
> If this is the case then the declaration embeddedsub would only be
> executed in the first iteration.
Actually, these declarations are "executed" (if that's the right word)
only at compile time; they have no effect on runtime.
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: 7 Jan 1998 01:26:13 GMT
From: "Nabil Courdy" <moab@emirates.net.ae>
Subject: Looking for perl
Message-Id: <01bd1ac9$538dea00$820de5c3@msdusr>
Where can I get the latest release of Perl for HP-UX
and DEC-UNIX?
Thx
moab@emirates.net.ae
=================
--
------------------------------
Date: 6 Jan 1998 17:36:54 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Looking for perl
Message-Id: <68tq3m$p43@mozo.cc.purdue.edu>
"Nabil Courdy" <moab@emirates.net.ae> writes:
}Where can I get the latest release of Perl for HP-UX
}and DEC-UNIX?
}Thx
}moab@emirates.net.ae
}=================
Try looking on the internet.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Tue, 06 Jan 1998 17:58:59 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Looking for perl
Message-Id: <34b270cb.1121945712@igate.hst.moc.com>
[original author automagically cc'd via e-mail]
On 7 Jan 1998 01:26:13 GMT, "Nabil Courdy" <moab@emirates.net.ae>
wrote:
>Where can I get the latest release of Perl for HP-UX
>and DEC-UNIX?
Rather than a smart-ass answer, I'll suggest http://www.perl.com/ as a
starting point.
Jeremy
--
Jeremy D. Zawodny jzawodn@wcnet.org
Web Server Administrator www@wcnet.org
Wood County Free Net (Ohio) http://www.wcnet.org/
------------------------------
Date: Tue, 06 Jan 1998 11:13:22 -0600
From: Chris Schmidt <chris@starkimages.com>
Subject: Lotus Notes
Message-Id: <34B26632.DE6BDF75@starkimages.com>
Does anyone know of a perl Module that as an api for Lotus notes DBS.
--
Chris Schmidt / Systems Manager
Stark Images
Phone / Fax
4142262700 / 4142262705
------------------------------
Date: 6 Jan 98 18:10:29 GMT
From: dwolfe@miaow.sps.mot.com (Dave Wolfe)
Subject: Re: Pattern match causing runtime exception
Message-Id: <dwolfe.884110229@talos4>
In <34B25387.14A2@math.uio.no> Peter John Acklam <jacklam@math.uio.no> writes:
>I want to match a chunk of Matlab code which is neither a string
>nor a comment, and I have come up with
[deleted]
>This regex works, but if the matched code is larger than 5648 bytes
>and it is only matched by the [^'%] part (i.e., code has no transpose
>operators), Perl crashes with a runtime exception.
>I use Perl for Win32
I tried your test case on an AIX 4.1 system running Perl 5.004_03 and
had no problems. Maybe you just have a bad Win32 port.
--
Dave Wolfe
------------------------------
Date: 6 Jan 1998 14:29:47 GMT
From: ricklim@vcn.bc.ca (Rick Lim)
Subject: Re: Perl & Win95 running a dos box
Message-Id: <68tf4r$frp@milo.vcn.bc.ca>
Is it possible using perl for windows to run a dos
box in win 95 and send it keystrokes just like a
human would, and then MARK, COPY, PASTE from the clipboard
the contents of the dos box back into the running perl app ???
--
The wealth of reality, cannot be seen from your locality.
------------------------------
Date: 6 Jan 1998 18:43:31 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl sort( ) Argument Passing Problem
Message-Id: <68tu0j$a0b$1@lyra.csx.cam.ac.uk>
MICHAEL JONES <michael.jones@EBay.Sun.COM> wrote:
>I have two questions relating to Perl sort functions. I am trying to
>write
>a module file that incorporates sort functions used in other scripts in
>a
>package.
>
>I would like to call the external subroutine like
>
>foreach $i ( sort External_Module->sort_subroutine ( keys %HASH ) ) {
>
> ...
>
>}
>
>1) When calling an external subroutine, the first argument passed to the
> subroutine is the module name (i.e. 'External_Module'). This seems
> to mess up the $a, $b arguments that sort passes to the sorting sub-
> routine.
You should call it as a subroutine, not as a method, i.e.
foreach $i ( sort External_Module::sort_subroutine ( keys %HASH ) ) {
>2) I would like to pass a reference to the hash to the sorting
>subroutine
> so I could sort on more than just the key, but I can't find a way to
> pass this reference without messing up $a and $b.
You'll need to put the subroutine in the scope of %HASH and refer to
%HASH by name. This can be achieved using a "glue" subroutine:
sub sort_glue { External_Module::sort_subroutine($a, $b, \%HASH) };
foreach $i ( sort sort_glue ( keys %HASH ) ) {
This also circumvents the problem of having to refer to $a and $b as
$MyPackage::a and $MyPackage::b.
But be warned that this style of coding can easily lead to the problems
Variable "%s" may be unavailable
Variable "%s" will not stay shared
currently being discussed in another c.l.p.m thread.
Mike Guy
------------------------------
Date: 6 Jan 1998 17:08:16 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: perldsc q: complex data from file
Message-Id: <68toe0$7ah$1@lyra.csx.cam.ac.uk>
Replying to my own posting,
>
>My first attempt went
>
>%data = do $tv_db;
>
>but that seems to provoke a bug in Perl:
>
>Bizarre copy of HASH in leaveeval at ...
Actually, it seems this error only occurs under the debugger. But you
still can't get a list result from do EXPR.
A better approach is probably to use eval rather than do, since eval
has no hangups about list results:
{ local $/;
open FILE, $tv_db or die "Cant open $tv_db: $!";
%data = eval scalar <FILE>;
close FILE or die "Can't close $tv_db: $!";
};
Mike Guy
------------------------------
Date: Tue, 06 Jan 1998 16:44:03 GMT
From: !pbuckley@tiac.net (Phil Buckley)
Subject: Querying info from other server
Message-Id: <34b25ef0.2891592@News.Varian.COM>
How would I go about querying stock prices from Yahoo or another
similar repository of stock info?
Thanks in advance,
Phil
Phil Buckley
pbuckley@tiac.net
http://www.tiac.net/intstute
remove the "!" before replying via e-mail
------------------------------
Date: 6 Jan 1998 18:23:47 GMT
From: klassa@aursgh.aur.alcatel.com (John M. Klassa)
Subject: Re: Review of CGI/Perl book
Message-Id: <68tsrj$2a0$1@aurwww.aur.alcatel.com>
On 6 Jan 1998 10:44:33 -0500, Mike Stok <mike@stok.co.uk> wrote:
->word for "dead" - how many people responsible for multiple machines feel
->pangs of anticipation when a new script needs a module which needs a new
->version of perl 5 or some existing module?
This definitely strikes a chord with me... Perl used to be perl, so to
speak -- one version, done. Now, I constantly feel the need to update and
upgrade this and that, and I'm never sure that things will work for
everybody who needs access. I get warm fuzzies less and less. :-)
--
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><
------------------------------
Date: Tue, 06 Jan 98 12:09:44 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: sending email (Net::SMTP).. problem
Message-Id: <34b265e3$6$ofn$mr2ice@speaker>
In <884058942.558011@cabal>, on 01/06/98 at 03:56 AM,
? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au> said:
+-----
| In <34B0ED52.CA7BC756@ti.com> Graham Barr <gbarr@ti.com> writes:
| >I know it is legitimate, I did not say it was not, I was just
| >trying to point out that SPAMmers use this techneque to avoid
| >the "junk mail" being traced back to them. And so is a good
| >target for filtering out unwanted mail.
| Spammers are more likely to point there devices at totaly unrealated servers
| so to relay them and make it difficalt to block. I haven't ever heard of
| your tactic being used.
+--->8
I've not only heard of it, I've *received* it. (Headers available on request:
for various reasons, I archive all received UCE. Unread, naturally.)
--
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)
------------------------------
Date: Tue, 6 Jan 1998 11:44:24 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: serious post about gmtime and year-1900 (was Re: Perl not Y2K compliant)
Message-Id: <19980106.114424.0G1.rnr.w164w@locutus.ofB.ORG>
pudge@pobox.com (Chris Nandor) writes:
>> personally, I'd guess that it's not just misreading, but also mistrust.
>> it's HEALTHY to mistrust anything that returns `98'. why not `1998'?
>
> Fine, mistrust it. But you can always check it out for yourself,
> can't you?
on non-production systems, you can set the clock to 2001 and see
what happens. and hope that it will continue behaving that way.
> $year = 60 * 60 * 24 * 365;
> @time = localtime(time() + $year * 3);
> print $time[5];
this might be a good thing to put in the documentation, instead of a
`trust me it will work' style claim.
it does all depend on the underlying C runtime supplying the correct
number -- and we all know there are no errors in the C runtime, right?
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Tue, 06 Jan 1998 12:33:49 -0600
From: "Craig A. Keefner" <keefner@kinetic.com>
Subject: Updating Perl 5.003 to 5.004 on Solaris 2.51
Message-Id: <34B2790D.2BB2B2B@kinetic.com>
I need to update my 5.003 with 5.004 so some new modules
i need to use work.
forgive me for asking but, will i need to reinstall any/all
of the already
installed modules on my 5.003 (like CGI.pm and/or others).
thanks
Craig
------------------------------
Date: Tue, 06 Jan 1998 12:33:30 -0600
From: nikkim@senate.leg.state.mn.us
Subject: Using perl to validate links
Message-Id: <884111147.1018757131@dejanews.com>
Is it possible to use Perl to check if HTML links on a page are active?
I would like to add this capability to our website so users will not get
a standard error message when a link is no longer valid and I can redirect
them elsewhere.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 06 Jan 1998 13:49:15 -0500
From: Clark Dorman <clark@s3i.com>
Subject: WebMirror 1.0 corrupting jpg files
Message-Id: <dn2h9wi8k.fsf@elmo.s3i.com>
Greetings,
I have been using WebMirror to mirror my web pages (at school)
at my work (with libwww 5.18). However, I have been having
difficulties with JPEG files. When they get transferred, the JPEG
files have an error (as reported by xv-3.10a):
Corrupt JPEG data: 10 extraneous bytes before marker 0xdb.
Has anyone had a similar error or recommend a solution?
My solution has been to start using w3mir-0.99b2, but I don't
like the interface as much.
--
Clark Dorman "Evolution is cleverer than you are."
http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
------------------------------
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 1589
**************************************