[13935] in Perl-Users-Digest
Perl-Users Digest, Issue: 1345 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 10 21:05:32 1999
Date: Wed, 10 Nov 1999 18:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942285913-v9-i1345@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 10 Nov 1999 Volume: 9 Number: 1345
Today's topics:
Re: Absolute path <cassell@mail.cor.epa.gov>
Re: create a folder and after a file... <fred@decatomb.com>
Re: create a folder and after a file... <cassell@mail.cor.epa.gov>
error code = 2 - need help <jhardman@att.net.hk>
file read/write conflicts? <vbenjam@provalue.net>
Re: file read/write conflicts? <lr@hpl.hp.com>
Re: file read/write conflicts? (Brian StJohn)
Re: file read/write conflicts? <cassell@mail.cor.epa.gov>
Re: Has anybody tried making Active Server Pages (IIS 4 <cassell@mail.cor.epa.gov>
Help! <qsun@kitco.com>
Re: Implementing persistence in Perl (Ilya Zakharevich)
Re: It is always like this here? <flavell@mail.cern.ch>
Re: mapping .cgi to .pl jobmail@my-deja.com
modifying an series of RCS files <navin@ti.com>
Re: Module File:Find problem (Martien Verbruggen)
Re: Module File:Find problem <cassell@mail.cor.epa.gov>
Re: perl & permission <lr@hpl.hp.com>
Re: perl + AI <cassell@mail.cor.epa.gov>
Re: perl as first language? (LONG) (Damian Conway)
Re: Perl Extensions. Arrgh. (Ilya Zakharevich)
Re: Perl Wizards (Martien Verbruggen)
Re: Perl Wizards <lr@hpl.hp.com>
Re: Perl Wizards <cassell@mail.cor.epa.gov>
Re: Perl Wizards <cassell@mail.cor.epa.gov>
Re: Perl Wizards <aqumsieh@matrox.com>
Re: Perl Wizards <lr@hpl.hp.com>
Re: PERLHUMOR: self-printing resume <rick.delaney@home.com>
Re: PERLHUMOR: self-printing resume <aqumsieh@matrox.com>
Q: Parsing a simple script language <thomas2@dalnet.se>
Re: replace " " with <lr@hpl.hp.com>
Re: Splitting at 255 bytes <cassell@mail.cor.epa.gov>
Re: Splitting at 255 bytes <sariq@texas.net>
system() fails to return error code <jeffc@genesyslab.com>
Re: Tim O Reilly interview. Very good read. (Ilya Zakharevich)
unable to run perl scripts on pws ltawfall@my-deja.com
Re: W95 & gethostbyname questions (Neil Cherry)
Re: W95 & gethostbyname questions <cassell@mail.cor.epa.gov>
Re: what is the difference between my() and local()? (Markus Svilans)
Re: what is the difference between my() and local()? (Eric Bohlman)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 10 Nov 1999 15:25:28 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Absolute path
Message-Id: <3829FEE8.F8215851@mail.cor.epa.gov>
Andrei Rjeousski wrote:
>
> is it possible to find absolute path of the directory without asking the
> administrator?
Check out the Cwd module. It's in the standard install now,
and it's portable.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 18:57:33 -0400
From: "Frédérick Giasson" <fred@decatomb.com>
Subject: Re: create a folder and after a file...
Message-Id: <3829F85D.EAC44D9@decatomb.com>
becose i cant change permission, delete the file and upload in this
directory
( the folder is set to 777 )
fred
Kragen Sitaker wrote:
>
> In article <38298A6D.8B980093@decatomb.com>,
> Frédérick Giasson <fred@decatomb.com> wrote:
> >this don't work!!!
>
> How do you know?
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 10 Nov 1999 17:04:32 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: create a folder and after a file...
Message-Id: <382A1620.5671B4CD@mail.cor.epa.gov>
Frédérick Giasson wrote:
>
> becose i cant change permission, delete the file and upload in this
> directory
>
> ( the folder is set to 777 )
Umm, do you mean that the file permissions are 0777 (777 in
octal, which is -rwxrwxrwx and should let anyone into the
directory), or that they are 777 (1411 octal, which is *not*
going to be helpful)?
If the directory (and any necessary parents) have permissions
letting you at the file, then the next question is on the
permissions for the file.
The question after that is "Just how are you trying to
access the file? Through a CGI script? Please be specific."
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 11 Nov 1999 08:32:49 +0800
From: "Justin Hardman" <jhardman@att.net.hk>
Subject: error code = 2 - need help
Message-Id: <80d2r9$m9p$1@m5.att.net.hk>
I just installed Active Perl build 522 on my NT server, and now I am getting
lots of error messages, that say "Win32 Error Code = 2," when I am running
SSI scripts. When I just run a perl script it is bringing up a 404 error
page.
Perl also seems to be running more more slowly now than before. Also
upgraded to SP6 recently so that may have something to do with it.
I need a solution to this fast, so if anyone has any ideas could you please
respond to me by e-mail! (990451@hkis.edu.hk)
Thanks.
------------------------------
Date: Wed, 10 Nov 1999 18:10:02 -0600
From: "Ben Valentine" <vbenjam@provalue.net>
Subject: file read/write conflicts?
Message-Id: <oInW3.1343$Up1.8045@newsfeed.slurp.net>
Does anyone know how perl or web servers in general handle an attempt by two
different invocations of the same perl script to read and write to the same
text file at the same time?
For example, if user A runs script.pl from their web browser. While
script.pl is reading from textFile.txt(for user A), user B starts script.pl
and an attempt is made to write to textFile.txt. Does user B (1) get a
server error, (2) have to wait until user A's process is done reading, (3)
corrupt the text file, or (4) cause something that I am not considering.
Whether you have an answer or just relevant info, please reply.
Thanks,
Ben
------------------------------
Date: Wed, 10 Nov 1999 16:55:28 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file read/write conflicts?
Message-Id: <MPG.1293b3d82db7127d98a1d4@nntp.hpl.hp.com>
In article <oInW3.1343$Up1.8045@newsfeed.slurp.net> on Wed, 10 Nov 1999
18:10:02 -0600, Ben Valentine <vbenjam@provalue.net> says...
> Does anyone know how perl or web servers in general handle an attempt by two
> different invocations of the same perl script to read and write to the same
> text file at the same time?
Poorly. :-)
> For example, if user A runs script.pl from their web browser. While
> script.pl is reading from textFile.txt(for user A), user B starts script.pl
> and an attempt is made to write to textFile.txt. Does user B (1) get a
> server error, (2) have to wait until user A's process is done reading, (3)
> corrupt the text file, or (4) cause something that I am not considering.
It depends on the operating system, but in general, it's Not Good.
> Whether you have an answer or just relevant info, please reply.
perldoc -f flock
perldoc -q flock
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 11 Nov 1999 00:55:03 GMT
From: bsj@fc.hp.com (Brian StJohn)
Subject: Re: file read/write conflicts?
Message-Id: <80d457$ipe$1@fcnews.fc.hp.com>
Ben Valentine (vbenjam@provalue.net) wrote:
: Does anyone know how perl or web servers in general handle an attempt by two
: different invocations of the same perl script to read and write to the same
: text file at the same time?
: For example, if user A runs script.pl from their web browser. While
: script.pl is reading from textFile.txt(for user A), user B starts script.pl
: and an attempt is made to write to textFile.txt. Does user B (1) get a
: server error, (2) have to wait until user A's process is done reading, (3)
: corrupt the text file, or (4) cause something that I am not considering.
: Whether you have an answer or just relevant info, please reply.
(4) cause something that I am not considering:
A text file is just a text file. If script.pl is reading from
textFile.txt while another script is writing to textFile.txt,
the first instance of the script will merrily read away on textFile.txt,
displaying the new data if you're dumping the data to the screen.
It won't corrupt your text file. Now, if multiple processes are
writing to that file - that's a different story.
Brian
------------------------------
Date: Wed, 10 Nov 1999 17:09:42 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: file read/write conflicts?
Message-Id: <382A1756.28FC7C80@mail.cor.epa.gov>
Ben Valentine wrote:
>
> Does anyone know how perl or web servers in general handle an attempt by two
> different invocations of the same perl script to read and write to the same
> text file at the same time?
Yes. Look in the Perl docs for discussions about flock().
There is even coverage of this issue in the FAQ. Try typing
this at a command prompt on a machine where Perl is accessible:
perldoc -q \block
[this looks for the keyword 'lock' while making sure not to
pick up the work 'block' too]
> For example, if user A runs script.pl from their web browser. While
> script.pl is reading from textFile.txt(for user A), user B starts script.pl
> and an attempt is made to write to textFile.txt. Does user B (1) get a
> server error, (2) have to wait until user A's process is done reading, (3)
> corrupt the text file, or (4) cause something that I am not considering.
Well, lots of people who fail to use flock() end up with option
number 3 there. Using flock() properly can give you option
number 2.
I think (4) is:
The clouds overhead part, and a booming voice shouts, "Stop it!
Web counters are stupid! Parse the server logs if you want this!"
:-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 16:53:16 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Has anybody tried making Active Server Pages (IIS 4.0) in active Perl?
Message-Id: <382A137C.721CCDB1@mail.cor.epa.gov>
Chris Beaver wrote:
>
> Just looking for some feedback in regards to making IIS 4.0 Active Server
> Pages with ActivePerl?
>
> How does it compare with VBscript?
Lots of people do this, with varying degrees of success.
You'll probably want to look at the archives of the Win32-Perl-
Web mailing list at www.activestate.com .
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 19:09:01 -0500
From: Qinqiang Sun <qsun@kitco.com>
Subject: Help!
Message-Id: <382A091D.C72D469E@kitco.com>
Hi, everybody,
I use perl win 32 building 515 and IIS4.0 on WinNT4.0.
We run perl scripts using PerlIS.dll and got extra stuff like
"HTTP/1.0 200 OK Date: Thu, 11 Nov 1999 00:07:10 GMT Server:
Microsoft-IIS/4.0 ".
Please help me to fix so we don't get this header again.
Thank you very much.
Sun
------------------------------
Date: 10 Nov 1999 23:43:18 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Implementing persistence in Perl
Message-Id: <80cvum$20b$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Jean-Louis Leroy
<jll@skynet.be>],
who wrote in article <m3n1smpz0f.fsf_-_@enterprise.newedgeconcept>:
> ilya@math.ohio-state.edu (Ilya Zakharevich) writes:
>
> > Hmm, I though we have it [weak references] already in the
> > development branch, do not we?
>
> I know that support for weak refs has been present for a while but the
> only mention I've been able to find (using grep) in the docs are in
> perldiag. I've tried weak($r) and weaken($r), to no avail.
>
> So, how do I use them?
You can use them from C, and I think there is a module on CPAN too.
Ilya
------------------------------
Date: Thu, 11 Nov 1999 00:30:50 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: It is always like this here?
Message-Id: <Pine.HPP.3.95a.991111002910.13340A-100000@hpplus01.cern.ch>
On 9 Nov 1999, Jonathan Stowe wrote:
> Isnt a buttload by definition Imperial ?
And your Perl language question is...?
No documentation for perl FAQ keyword `buttload' found
No documentation for perl FAQ keyword `Imperial' found
[sorry, couldn't resist]
------------------------------
Date: Wed, 10 Nov 1999 23:59:12 GMT
From: jobmail@my-deja.com
Subject: Re: mapping .cgi to .pl
Message-Id: <80d0se$na1$1@nnrp1.deja.com>
In article <38284f9e_1@newsread3.dircon.co.uk>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> jobmail@my-deja.com wrote:
> > I am trying to run perl scripts on Infradig web server on win95.
When
> > I run scripts with .pl they work fine. When I change the
extentions
> > from .pl to .cgi I get an error message -- 'doc. contains no data'.
> > Can anyone help me to map .cgi extention to .pl ? Thanks.
> >
>
> I'm sure those nice people in comp.infosystems.www.servers.ms-windows
can.
>
>
Thank you! That was the first place I posted my message to....
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 10 Nov 1999 18:25:58 -0600
From: Navin Chander <navin@ti.com>
Subject: modifying an series of RCS files
Message-Id: <382A0D16.B0BDEE37@ti.com>
I have a series of files in RCS. I have to do the same modification to each file.
I am trying to do it using perl. but the problem is, when I check the file back in,
RCS requires an input. Can someone tell me how to do that in perl.
thanks
navin
------------------------------
Date: Wed, 10 Nov 1999 23:10:21 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Module File:Find problem
Message-Id: <slrn82juqt.4hc.mgjv@verbruggen.comdyn.com.au>
On Wed, 10 Nov 1999 12:43:14 -0800,
Bin Zeng <zeng@stat.Berkeley.EDU> wrote:
> The Module File:Find can be used to process files in a
> directory recursively. But I got a problem with the linked directory.
[snip]
> Anyone has a fix for this?
# man File::Find
[snip
BUGS
There is no way to make find or finddepth follow symlinks.
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Wed, 10 Nov 1999 15:23:14 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Module File:Find problem
Message-Id: <3829FE62.FE027C25@mail.cor.epa.gov>
Bin Zeng wrote:
[snip]
> find ( sub { print $File::Find::name, "\n"} , @d );
>
> This code works fine for regular directory. But if the directory
> '/bin' is a symbolic link, (I mean when 'ls -l /bin', the result is
> something like
> lrwxrwxrwx 1 root root Jul 8 21:54 /bin -> ./usr/bin
>
> Then the code fails to work. What I mean by this is that the code
> is supposed to print out the names of all the files in the directory
> /bin. But if /bin is a linked directory, the output for the code is
> just '/bin'.
Umm, if you read the docs for File::Find you will see a specific
note about symlinks. It says:
"There is no way to make find or finddepth follow symlinks."
If you think about how symlinks can be set up, you'll see that
this is considered to be A Good Thing by some.
If you need to follow symlinks, you'll need to push them
onto a stack and then follow them using your own code. Think
about how you'll get back to a place where the next symlink
can be followed, and how you'll cope if a symlink points to
itself, or to a series of symlinks which will eventually
put you back at that first symlink, in an infinite loop.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 15:38:53 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: perl & permission
Message-Id: <MPG.1293a1e56187c78598a1d2@nntp.hpl.hp.com>
In article <3829F59A.69855D2D@mail.cor.epa.gov> on Wed, 10 Nov 1999
14:45:46 -0800, David Cassell <cassell@mail.cor.epa.gov> says...
...
> Shlomit Afgin wrote:
...
> > my script contain:
> > if ((-e $files[$i]) &&
> > (((-f $files[$i])&&(! -r $files[$i]))||((-d $files[$i])&&( !-x
> > $files[$i])))){
> > print BAD "$files[$i]\n";
> > }
>
> Ugh. All those parens make my eyes hurt. Check out the
> precedence of the -X functions vs. && [or 'and'] and you
> can make this easier to read.
You might also consider that doing successive stats on the same file is
costly. The magic identifier _ obviates this.
if (-e $files[$i] && (-f _ && ! -r _ || -d _ && ! -x _)) {
print BAD "$files[$i]\n";
}
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Nov 1999 15:07:58 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perl + AI
Message-Id: <3829FACE.4BAABABA@mail.cor.epa.gov>
GB wrote:
>
> Im looking for a programmer with a good inside knowledge of PERL/CGI and an
> understanding of the basics of AI to team up with for a business venture
> involving internet advertising. Im based in London so it would be mutually
> beneficial if you were too.
You might have better luck if you post this in a newsgroup
about jobs, preferably one which has 'jobs' and 'uk' in its
name. Or see about a jobs board for your local Perl Mongers
affiliate.
Using the PSI::ESP module, I see that you'll need someone who
knows more than the 'basics' of AI. What you want to do is
harder than you think.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 11 Nov 1999 01:09:09 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: perl as first language? (LONG)
Message-Id: <80d4vl$amn$1@towncrier.cc.monash.edu.au>
kragen@dnaco.net (Kragen Sitaker) writes:
>> Unfortunately she's in Japan presenting the paper and won't be back till
>> December :-( :-(
>
> Maybe you should ask her to give you a copy of the TeX source? Has she
> no telnet access in Japan?
Sorry, I can't contact her before December.
>> Apologies all round, but it seems I don't have a copy available until
>> then.
> I'm curious what you think of Python and Scheme for this purpose,
> and I'm very interested in the results of your research.
You should probably talk with my postgrad (Linda McIver) directly:
lindap@csse.monash.edu.au
> strings | perl -ne 'print if /[a-zA-Z]{5}/ and not (/TimesNewRmn/ or
> /Courier/ or /Arial/)' yields the following. I hope it is helpful.
It is. At least it gives interested folks a taste, until Linda returns.
Damian
------------------------------
Date: 10 Nov 1999 23:50:35 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl Extensions. Arrgh.
Message-Id: <80d0cb$225$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Dan Sugalski
<dan@tuatha.sidhe.org>],
who wrote in article <AziW3.2915$c06.24415@news.rdc1.ct.home.com>:
> > I noticed. But my remark still stands: what do you think is the
> > declaration of RETVAL? It is C, not Perl, variables have types...
>
> It's not C, it's XS. C with a heap of funky preprocessing done.
My question was about the result of conversion to C.
Ilya
------------------------------
Date: Wed, 10 Nov 1999 23:19:54 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Wizards
Message-Id: <slrn82jvcr.4hc.mgjv@verbruggen.comdyn.com.au>
On Wed, 10 Nov 1999 22:57:03 GMT,
Kragen Sitaker <kragen@dnaco.net> wrote:
> In article <3829F31C.43B4EF0E@mail.cor.epa.gov>,
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> >[no wizards are likely to answer a Subject: line like that - in
> >future, please write a more descriptive subject]
>
> The fact of your posting contradicts your words :)
He said likely. This is just an exception :)
Martien
--
Martien Verbruggen |
Interactive Media Division | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Wed, 10 Nov 1999 15:43:55 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl Wizards
Message-Id: <MPG.1293a3135ba570a298a1d3@nntp.hpl.hp.com>
In article <3829F31C.43B4EF0E@mail.cor.epa.gov> on Wed, 10 Nov 1999
14:35:08 -0800, David Cassell <cassell@mail.cor.epa.gov> says...
> Nobody wrote:
...
> > grep(m!$/bin/(.{10}) ! && $ps{$1}++, &safe_backtic("ps -ef"));
> >
> > I don't understand the first pattern matching statement (or if it is a
> > pattern matching statement !) m! ....!
> > What do the ! ... ! do ?
>
> Neither do I. The ! ... ! are acting as an alternative to the
> usual m// , but I don't see how this can match anything, when
> $ matches the end-of-line.
Ooh. Look again. As has already been noted, that leading '$'
interpolates the value of '$/', not matches 'end-of-line'. So it is
approximately a 'start-of-line' anchor.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Nov 1999 16:55:16 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl Wizards
Message-Id: <382A13F4.3B433F9B@mail.cor.epa.gov>
Kragen Sitaker wrote:
>
> In article <3829F31C.43B4EF0E@mail.cor.epa.gov>,
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> >[no wizards are likely to answer a Subject: line like that - in
> >future, please write a more descriptive subject]
>
> The fact of your posting contradicts your words :)
Flattery will get you nowhere. Well, okay, it will get you
pretty much what you want. I'm easy.
But I don't consider myself a Perl wizard. Just a satisfied
customer. Abigail, Larry, Uri, Damian... They're wizards.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 16:58:23 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl Wizards
Message-Id: <382A14AF.27EBC587@mail.cor.epa.gov>
Larry Rosler wrote:
[snip]
> Ooh. Look again. As has already been noted, that leading '$'
> interpolates the value of '$/', not matches 'end-of-line'. So it is
> approximately a 'start-of-line' anchor.
Mea culpa. I thought I checked that first. See, I *told*
Kragen I wasn't a wizard. :-)
So how in the Sam Hill is 'bin' at the very beginning of a line
with no prior spaces ever going to match anything output from
`ps -ef` ? It doesn't come close on the versions of ps with
which I am familiar.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 19:22:13 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Perl Wizards
Message-Id: <x3y7ljpzxl6.fsf@tigre.matrox.com>
kragen@dnaco.net (Kragen Sitaker) writes:
> In article <80c49t$9r2@courier.xilinx.com>,
> Jeff Stampes <stampes@xilinx.com> wrote:
> >Please try and select more useful subject lines. This is not a
> >question for a 'wizard', and indeed most 'wizards' will likely
> >ignore it, or flame you for using such a poor subject line.
>
> I"m not a wizard either.
>
> >Nobody <nobody@logica.com> wrote:
> >: grep(m!$/bin/(.{10}) ! && $ps{$1}++, &safe_backtic("ps -ef"));
> >
> >Let's see...this seems very strange to me...It is a pattern match, they
> >are simply using m!! instead of m// so they won't have to escape their
> >slashes. That part is easily understood.
> >
> >However, I'd be surprised if this works as expected. The match, as I
> >understand it, is looking for an occurance of $/ (input record
> >separator), followed by 'bin/' and then ten characters and a space.
>
> Yes -- most bizarre. Presumably this is meant to match a user with an
> 8-char username that starts with 'bin/' -- an atypical string with
> which to start a username, for sure. (It has to be 8-char -- at least
> on Solaris, where the usernames in the first column are
> right-justified.) Perhaps the $ is a mistake -- in that case, they
> could be looking for commands in a bin directory.
I believe "Nobody" is trying to match a command prompt:
$/bin/abcdefgh >
or something of the sort. But, I've been wrong before.
> Looks like crappy code to me, but maybe it's really good code doing
> something I don't understand.
No. Coming from someone with a nickname "Nobody", I wouldn't assume it
was that good.
Again, I might be wrong.
--Ala
------------------------------
Date: Wed, 10 Nov 1999 17:58:15 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl Wizards
Message-Id: <MPG.1293c290ecff6eaf98a1d5@nntp.hpl.hp.com>
In article <382A14AF.27EBC587@mail.cor.epa.gov> on Wed, 10 Nov 1999
16:58:23 -0800, David Cassell <cassell@mail.cor.epa.gov> says...
> Larry Rosler wrote:
> [snip]
> > Ooh. Look again. As has already been noted, that leading '$'
> > interpolates the value of '$/', not matches 'end-of-line'. So it is
> > approximately a 'start-of-line' anchor.
>
> Mea culpa. I thought I checked that first. See, I *told*
> Kragen I wasn't a wizard. :-)
>
> So how in the Sam Hill is 'bin' at the very beginning of a line
> with no prior spaces ever going to match anything output from
> `ps -ef` ? It doesn't come close on the versions of ps with
> which I am familiar.
Well, $/ could be "\n ", which would match a user 'bin' on my HP-Ux
system. But what about that '/' after 'bin'? I agree, it's hopeless.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Nov 1999 23:38:18 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: PERLHUMOR: self-printing resume
Message-Id: <382A0201.744EBCBC@home.com>
[posted & mailed]
Jeff Pinyan wrote:
>
> [posted & mailed]
>
> On Nov 10, Rick Delaney blah blah blah:
>
> > strict wouldn't catch that since $a and $b are exempt as the globals
> > used by sort. An oversight on your part, I'm sure, but I point this out
> > in case someone actually tries it and is confused.
> >
> > This is poorly documented. I knew it but couldn't find it anywhere in
> > the docs. Anyone?
>
> I went right to sort()'s documentation, where I expected it:
As others have pointed out, that is not really an obvious place to look
if you are confused about why strict isn't complaining that you didn't
declare $a.
I think the most obvious place would be the docs for strict, the next
best place perlvar.
Oh, and btw, it is NOT documented in C<sort>'s documentation. Nowhere
there does it say or imply that $a and $b are exempt from declaration
under strict. What it says is that you will have problems if you do
declare them as lexicals. It then describes ways to get around those
problems if you are silly enough to not take the advice.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 10 Nov 1999 19:16:24 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: PERLHUMOR: self-printing resume
Message-Id: <x3y9045zxuv.fsf@tigre.matrox.com>
Mike Coffin <mhc@Eng.Sun.COM> writes:
> abigail@delanet.com (Abigail) writes:
>
> > Well, it's documented at the most obvious place: perldoc -f sort.
>
> "Hmmmm.. I wonder if $a or $b are somehow special in Perl. Let's
> see: the index of the Camel book doesn't have anything relevant under
> 'a', 'b', '$a', or '$b'. And neither 'perldoc \$a' nor 'perldoc \$b'
> return anything....
>
> "However, just to be sure, I'll type 'perldoc -f sort'; maybe
> $a and $b are documented there."
Obvious, eh?
I think that $a and $b should be also documented in perlrun. Maybe
even in perlvar where it discusses $^W.
That's the best I can come up with now.
--Ala
------------------------------
Date: Thu, 11 Nov 1999 02:49:53 +0100
From: "Thomas Åhlen" <thomas2@dalnet.se>
Subject: Q: Parsing a simple script language
Message-Id: <80d7bo$1hq$1@gordon.dalnet.se>
Howdy!
I have made a perl package that parse an html template and inserts data from
an MySql database.
To make things a bit dynamic i have made a little script language which i
insert in the templates.
Well it might look something like this:
<html>
@@product_group@@
<table>
<!--products_LOOP_START-->
<tr>
<!--A_IF product_price > 100 -->
<td>@@product_name@@</td><td>@@product_description@@</td>
<!--A_IF_END-->
<!--A_ELSE-->
<td
color="ff0000">@@product_name@@</td><td>@@product_description@@</td>
<!--A_ELSE_END-->
</tr>
<!--products_LOOP_STOP-->
</table>
</html>
Currently i use regular expressions to match the blocks and do the
insertion.
But i don't like it. If i want to insert some new functionality there will
be
some regs. to change an it doesn't feel good or dynamic.
Someone with experience with this kind of problem.
What is the best way to make a simple parser that handles nested
if, elsif och elses and some other homebrewed tokens.
Bison, yacc?
We used yacc in school a couple of years ago, I hardly remeber it now.
Is it worth relearning for the problem described above?
Well all you perl experts how do you do it..:)
Over and out.
Thomas Åhlen
------------------------------
Date: Wed, 10 Nov 1999 15:21:38 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: replace " " with
Message-Id: <MPG.12939ddda46b2e4698a1d1@nntp.hpl.hp.com>
In article <003f01bf2b96$09903e00$8b00000a@aascatl.com> on Wed, 10 Nov
1999 11:09:57 -0500, Curtis Jones <curtisj@bannerfusion.com> says...
> For each item in the array @list, it globally replaces all occurences of " "
> with " ".
>
> I hope.... :-)
>
> my $lcnt = -1;
> foreach ( @list ) {
> $lcnt++;
> $list[$lcnt] =~ s/ /\ /g;
> print $list[$lcnt] . "\n";
> }
Others have pointed out that the regex is wrong. But the code itself is
bloated.
You seem not to be aware that on each iteration of the loop, $_ is set
to refer to the variable in the array. So that all can be written
simply as:
foreach ( @list ) {
s/ /\ /g;
print "$_\n";
}
If you are incrementing array indexes, there is likely to be a 'better'
(more Perlish) way.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Nov 1999 15:15:36 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Splitting at 255 bytes
Message-Id: <3829FC98.3A4E02D3@mail.cor.epa.gov>
raju_k@iname.com wrote:
[snip]
> There's probably a better way to do this with split() with an expression
> like /([.\n]){255}/ but I haven't tried it and it doesn't 'look' right.
There is a way to do it, but it isn't necessarily 'better'.
> A brute force method (I can just see the purist preparing a diatribe):
>
> my $LEN = 255
> my $str = "";
> my @substrs = '';
> my $len = 0;
> # generate some long string and store in $str and get it's length
> ...
> $len = length($str);
>
> # get the substrings
> for(my $i = 0; $_ = substr($str, $i, $LEN); ){
> # you can blindly do a $i += $LEN above if you don't care about
> # warnings
Or you can sneak the test into your for() loop to handle it.
> $i += (($i + $LEN) <= $len) ? $LEN : $len - $i;
> push(@substrs, $_);
> }
[Since you insist]
<diatribe>
It's usually faster if you can stick with the Perl ops.
See Greg Bacon's one-liner in this thread.
</diatribe>
Happy now? ;-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 10 Nov 1999 17:26:30 -0600
From: Tom Briles <sariq@texas.net>
Subject: Re: Splitting at 255 bytes
Message-Id: <3829FF26.1F711586@texas.net>
Thomas Brian Holdren wrote:
>
> All I want to do is... I have a big long $string. I want to break it up into
> an @array, every 255 bytes for entry into mySQL. I have tried unpack with A,
> but it only gets the first section (which the perl book said it would) like so:
>
> @array = unpack 'A255', $string;
>
> but only one element gets returned. *sigh*.
TMTOWTDI, but this seems to work:
use POSIX;
my @array = unpack 'A255' x ceil(length($string)/255), $string;
- Tom
------------------------------
Date: Wed, 10 Nov 1999 16:58:08 -0800
From: Jeffrey Croft <jeffc@genesyslab.com>
Subject: system() fails to return error code
Message-Id: <382A14A0.C0DC075B@genesyslab.com>
I am using a perl script to do this:
chdir("/path/to/foo") || die "chdir failed: $!\n";
$rc = system("/bin/tar cf foo.tar *")
When tar fails, the value of $rc is zero. However, I can go to the shell
and type the same commands:
cd /path/to/foo
/bin/tar cf foo.tar *
echo $status
and it prints 2.
I have also tried checking the value of $? but it's always zero after
this failed command, using either the system operator (not to be
confused with the system operator) or backticks.
What gives? I want to be sure that tar did its job before moving on.
Thanks,
Jeff Croft
jeffc@genesyslab.com
------------------------------
Date: 11 Nov 1999 00:01:20 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Tim O Reilly interview. Very good read.
Message-Id: <80d10g$24j$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Michael Houghton
<herveus@Radix.Net>],
who wrote in article <80c02d$3tc$1@saltmine.radix.net>:
> >http://www.softwareireland.com/terrybyte/tim_oreilly.asp
> >
> It would be much easier to digest if you did not force the font size
> so small. Parts of that page are completely unreadable, since I am
> not using a platform which understands "verdana" as a font.
Eh??? Use lynx!
Ilya
------------------------------
Date: Thu, 11 Nov 1999 01:06:22 GMT
From: ltawfall@my-deja.com
Subject: unable to run perl scripts on pws
Message-Id: <80d4qc$q85$1@nnrp1.deja.com>
I've been trying to run a >basic< perl script on my personal
web server that I installed when I installed win98se.
The web server itself works fine with regular html pages.
I checked the MS knowledge base for help and the activestate perl help
docs and nothing works yet.
I had the server installed pior to installing the latest
version of active perl. I looked around for some help, and
found out I need to put stuff in the registry. So I put
".pl" "c:\perl\bin\perl.exe %s %s" and
".plx" "c:\perl\bin\perlis.exe"
in the registry under
HKEY_LOCAL_MACHINE\system\currentcontrolset\services\W3SVC\Parameters\Sc
ript map
restarted the machine a couple of times, still doesn't work. Basically
when I tried run the script (straight from the knowledge base):
------------------------------------
print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Hello World</TITLE>\n";
print "</HEAD>\n";
print "<BODY>\n";
print "<H4>Hello World</H4>\n";
print "<P>\n";
print "Your IP Address is $ENV{REMOTE_ADDR}.\n";
print "<P>";
print "<H5>Have a nice day</H5>\n";
print "</BODY>\n";
print "</HTML>\n";
---------------------------
the helloworld.pl times out and helloworld.cgi gives me a "HTTP/1.1 500
Server Error"
my scripts are in the default scripts directory in the pws. (Everything
is installed with the accepted defaults)
I'm out of ideas, I didn't really think it should be this difficult to
run perl scripts on my own machine. I don't have this problem running
them on real web servers.
Thanks for any help.
-Lisa
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 11 Nov 1999 00:43:34 GMT
From: njc@dmc.uucp (Neil Cherry)
Subject: Re: W95 & gethostbyname questions
Message-Id: <slrn82k47m.m0v.njc@dmc.uucp>
On Wed, 10 Nov 1999 22:25:29 GMT, Neil Cherry wrote:
>I've create a simple program which works under Linux. Now when I try
>to get it to work it can't find the host. My question is where does
>Perl/W95 expect to find the hosts file?
Never mind, I found that the gethostbyname does a DNS lookup first
(sniffers are great tools). I'm on an internal network with no DNS.
It eventually times out and the does a lookup of c:/windows/hosts .
--
Linux Home Automation Neil Cherry ncherry@home.net
http://members.home.net/ncherry (Text only)
http://meltingpot.fortunecity.com/lightsey/52 (Graphics GB)
------------------------------
Date: Wed, 10 Nov 1999 17:14:01 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: W95 & gethostbyname questions
Message-Id: <382A1859.C169A70F@mail.cor.epa.gov>
Neil Cherry wrote:
>
> On Wed, 10 Nov 1999 22:25:29 GMT, Neil Cherry wrote:
> >I've create a simple program which works under Linux. Now when I try
> >to get it to work it can't find the host. My question is where does
> >Perl/W95 expect to find the hosts file?
>
> Never mind, I found that the gethostbyname does a DNS lookup first
> (sniffers are great tools). I'm on an internal network with no DNS.
> It eventually times out and the does a lookup of c:/windows/hosts .
You might want to check the FAQ too. Type this at a command
prompt:
perldoc -q hostname
I know you're blushing now...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Thu, 11 Nov 1999 00:53:29 GMT
From: bh447@freenet.carleton.ca (Markus Svilans)
Subject: Re: what is the difference between my() and local()?
Message-Id: <382a1346.6666888@news.ncf.carleton.ca>
Hey guys take it easy, ok?
My fault, I should read the FAQ more often but I'm lazy like probably
a lot of you are and I find it easier to post my stupid questions
here. :) I hope I don't do it too often.
-Markus
>>Tad, shut the fuck up, eh?
>
>
> I am unable to comply with your eloquently phrased request.
>
> Thank you for your input though.
>
>
>
> Post a FAQ, get flamed. That's just how it is on Usenet.
>
> (although my followup wasn't particularly harsh, I even put
> a couple of smileys in there...
> )
>
>
>> It's one thing to be frustrated that people
>>don't know about FAQs or don't read them. It's something else entirely
>>to go looking for excuses to call people idiots.
>
>
> It was Markus, not me, that characterized him as an idiot.
>
> Direct your curses at _him_.
>
>
>--
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
--
Rainy days and automatic weapons always get me down.
------------------------------
Date: 11 Nov 1999 01:22:17 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: what is the difference between my() and local()?
Message-Id: <80d5o9$qn$1@nntp6.atl.mindspring.net>
Markus Svilans (bh447@freenet.carleton.ca) wrote:
: My fault, I should read the FAQ more often but I'm lazy like probably
: a lot of you are and I find it easier to post my stupid questions
: here. :) I hope I don't do it too often.
Er, "lazy" has a very precise technical meaning in the context of Perl.
It means the quality of mind that makes you go to great effort to reduce
the world's total energy expenditure. Writing answers to FAQs is an
example of Laziness; it reduces the energy expenditure of tens of
thousands of people. That is a Good Thing. Asking FAQs in a newsgroup is
an example of False Laziness; it slightly reduces your energy expenditure,
or should I say *might* reduce it, at the expense of slightly increasing
the energy expenditure of tens of thousands of people. That is a Bad
Thing.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 1345
**************************************