[15699] in Perl-Users-Digest
Perl-Users Digest, Issue: 3112 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 21 14:05:26 2000
Date: Sun, 21 May 2000 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958932310-v9-i3112@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 21 May 2000 Volume: 9 Number: 3112
Today's topics:
Re: Any body know how I access serial ports(unix) (William Herrera)
Re: Bug or Feature: Can't dereference array ref inside (Bart Lateur)
Re: Bug or Feature: Can't dereference array ref inside <tcuffel@exactis.com>
Re: file locking <godzilla@stomp.stomp.tokyo>
Re: Forum for 'how to do it' questions? (Andreas Ringstad)
Re: Forum for 'how to do it' questions? <ra.jones@NO_UCE*cwcom.net>
Garbage Collection <tcuffel@exactis.com>
Global variables to apply to multiple Perl scripts <apietro@my-deja.com>
Re: Global variables to apply to multiple Perl scripts <sweeheng@usa.net>
Re: Is this the right behaviour for Net::SMTP/Cmd? (Bart Lateur)
ISP for experimenting? <rsm@loop.com>
Re: perl to lunch "Save As" browser window ??? <flavell@mail.cern.ch>
Re: perl to lunch "Save As" browser window ??? <flavell@mail.cern.ch>
Re: regexes *sigh* damn I hate these things <godzilla@stomp.stomp.tokyo>
Re: regexes *sigh* damn I hate these things (Bart Lateur)
Re: regexes *sigh* damn I hate these things <Tbone@pimpdaddy.com>
REGEXP newbie question (Dr. Smith)
Re: Regular expression ? (Mark-Jason Dominus)
Re: Regular expression ? (Mark-Jason Dominus)
Re: Resource Temporarily Unavailable <gellyfish@gellyfish.com>
Sendmail problem! <ppi@searchy.net>
Re: Sendmail problem! <elaine@chaos.wustl.edu>
Re: SSI in Perl Script ? <andy@u2me3.com>
Re: the use of $_ (Mark-Jason Dominus)
Re: the use of $_ <godzilla@stomp.stomp.tokyo>
Re: Untaint URL character class <godzilla@stomp.stomp.tokyo>
Re: Untaint URL character class <gellyfish@gellyfish.com>
Re: valid email address (Neil Kandalgaonkar)
Re: valid email address <sweeheng@usa.net>
Re: What's this line which Perl added to AUTOEXEC.BAT? (William Herrera)
Re: What's this line which Perl added to AUTOEXEC.BAT? (William Herrera)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 14 May 2000 19:54:54 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: Any body know how I access serial ports(unix)
Message-Id: <391f0428.239078@news.rmi.net>
On Sun, 14 May 2000 22:21:44 +1000, Stephen Lohning <stephen@oxnee.com> wrote:
try Device::SerialPort also:
http://www.cpan.org/modules/by-module/Device/Device-SerialPort-0.070.tar.gz
>Does any body how how I can access serial ports on a linux
>Redhat 5.2 machine.
>Which CPAN module should I look for?
>
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Sun, 21 May 2000 16:01:43 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Bug or Feature: Can't dereference array ref inside hash
Message-Id: <3928f052.2543851@news.skynet.be>
Steve Leibel wrote:
>I still
>freely admit I don't understand the deeper meaning of "Odd number of
>elements in hash assignment" in response to
>
>$myhash = {
> whatever => (),
>};
>
>So maybe it's not just me being clueless, perhaps this is a confusing part
>of the language and a lot of readers could benefit from a clear
>explanation of this example.
Let's see if you see the difference bewteen the next two lines:
@ary = ();
and
@ary = [];
The former will assing an empty list, i.e. a list of zero elements, to
@ary. So now, @ary will have zero elements.
In the latter, you assign a scalar, a reference to an empty anonymous
array, to @ary. Now, @ary will contain one element: an array reference.
In short: () is an empty list, [] is a scalar, in particular, an array
reference.
So:
@list = ( whatever => () );
is the same as
@list = ( 'whatever', () );
or
@list = ( 'whatever' );
There is one scalar in this list. Assign this to a hash, and you'll get
the "odd number of hash elements" warning.
By contrast,
@list = ( whatever => [] );
is the same as
@list = ( 'whatever', [] );
which contains two scalars: a literal string, and an array reference.
--
Bart.
------------------------------
Date: Thu, 18 May 2000 11:27:08 -0500
From: "Tim" <tcuffel@exactis.com>
Subject: Re: Bug or Feature: Can't dereference array ref inside hash
Message-Id: <zuVU4.1245$P4.3267@den-news1.rmi.net>
Steve Leibel wrote in message ...
>If I have a hash reference, one of whose keys is an array ref, like this:
>
>$myhash = {
> arrayref => (),
>};
There is your first problem. [] is the anonymous array constructor, not
(). () is an empty list, which gets interpolated into the the list
in the anonymous hash constuctor:
$myhash = { arrayref => () }; becomes
$myhash = { 'arrayref', () }; becomes
$myhash = { 'arrayref' };
>In theory I should be able to dereference the arrayref using syntax such as
>
> @$myhash->{arrayref}
@{$myhash->{'arrayref'}}, actually
>However every variant of that gets errors, as the following program shows.
>#!/usr/local/bin/perl
Your second problem. Where is -w? This would have given
a 'Odd number of elements in hash assignment' warning, telling
you exactly where the error was.
-T
------------------------------
Date: Sun, 21 May 2000 09:04:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: file locking
Message-Id: <39280918.1D35AE80@stomp.stomp.tokyo>
Dave Cross wrote:
> "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> >Tad McClellan wrote:
> >> Godzilla! <godzilla@la.znet.com> wrote:
> >> >Cure wrote:
> >> >flock (FILE_HANDLE, 2)
> >> >flock (FILE_HANDLE, 8)
> >> >Both are old fashion strict methods of
> >> >locking and unlocking a file, respectfully.
> >> ^^^^^^^^^^^^
> >> If you don't talk nice to your filehandles they
> >> won't do what you ask?
> >Those of us well educated in Language and Linguistics
> >are aware "respectfully" within this context means,
> >"Reference to the order given previously."
> Are you sure you don't mean "respectively"?
Of horse snot Mr. Cross. I am well known for showing
how petty many people are in news groups, for showing
how so many people are willing cause problems for the
lamest of reasons, and point a shakey finger of
hypocrisy at others, a shakey finger casted blame.
I twist no arms, I hold no gun to a person's head.
These decisions people make to cause problems, are
made by freewill choice, just as their decisions to
blame all problems on others, even problems of their
making, is a freewill choice.
People around here, around all news groups, everywhere
in life, many of these people put a lot of effort into
causing problems and spreading hatred, every chance
they get, as a freewill choice.
In this case, a single word caused many here to get
their diapers in a knot and show their true colors.
Reality is my game, Mr. Cross.
Godzilla!
------------------------------
Date: 21 May 2000 11:08:09 -0400
From: aringsta@panix.com (Andreas Ringstad)
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <8g8u4p$cru$1@panix.com>
In article <Pine.GHP.4.21.0005211426560.27796-100000@hpplus01.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>
>So what they need, in addition to advice about the Perl language, is
>advice in overall application design strategies and, very often, also
>in basic troubleshooting (how to instrument their code so that it
>reports to them what's going wrong and where, instead of falling in a
>gibbering heap).
>
>I don't know the solution to this dilemma.
not so long ago, when i was learning perl as a first
language, i approached this news group with a couple of simple
stupid questions inspired by lofty goals and necessitated by
near-total ignorance.
i got answers; they were prolly even the right answers.
were they really helpful? in the very short run, yes -- i
got one less error message for that evening. in the long
run, no -- i continued to write clueless code.
the only magic pill for perl headaches, i eventually found
out, is to *learn the basics* -- i.e., read and reread the
documentation for the language. after months of cursing out
perl, telnet, my service provider, ac electricity, etc., i
finally made the basic assumption necessary for learning
anything -- "I am a total dipsh.t., and need to second-guess
myself at every turn." -- and ran with it. i've been happy
ever since.
as for using this ng to learn perl: yes, reading the sage
replies of the regulars can help. trying to answer some of
the questions -- if only privately -- is infinitely more
effective.
d
--
_______________________________________________________________________
"Spit in the water cooler for me. Don't give aringsta@panix.com
up hope." www.panix.com/~aringsta
--jdk (Wed, 03 Mar 1999 22:13:53 PST)
------------------------------
Date: Sun, 21 May 2000 18:55:00 +0100
From: jones <ra.jones@NO_UCE*cwcom.net>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <4FafVLA0LCK5EwLH@cwc.com>
On Sun, 21 May 2000 at 14:57:47, Alan J. Flavell <flavell@mail.cern.ch>
wrote:
>Many of the problems are what people here call X/Y problems. They
>originally perceived a requirement, X, which they haven't told us
>about. They've concluded that the requirement can be fulfilled with
>Y, consisting of (let's say) some HTML, some Javascript, a couple of
>dubious Perl scripts that they picked up somewhere, and now they find
>they're stuck. So they tell the group about where they are stuck, i.e
>Y (but they shouldn't really have got themselves there in the first
>place), but they reveal little or nothing about what requirement, X,
>they were trying to address. (In this particular example, they would
>clearly have been better off raising their requirement on an
>appropriate comp.infosystems.www.* group, maybe .authoring.cgi, but
>that was only one possible example).
I can see the point here. In my case, I had some code which did actually
work, but was rather long-winded, and I wanted to seek advice as to how
to code it 'correctly'. I received that advice.
>I don't know the solution to this dilemma. I've kind-of grown up with
>programming, (probably learned lots of bad habits - there's an old
>saying that "physicists write FORTRAN in any language") and I can no
>longer see how it would be appropriate to start off a beginner. One
>thing is clear, however, and that is that you stand to benefit by
>taking a look at what more-experienced folks do and how they do it -
>at least, those who are willing to set it down on for us. Can I say
>"WebTechniques" for one example? And as far as the FAQs are
>concerned, a two strand approach is recommended. First, read them
>through. Some of them won't yet make sense, but read them anyway,
>and
>get a flavour of what's there.
I am presently working my way through the vast expanse of Perl FAQ
documents I have been pointed to recently. Doubtless I will learn a
great deal, but also still miss a lot of it. What do you mean
'WebTechniques'? Is this a specific document or web-site, or are you
suggesting I do a general Internet search on this keyword?
>And in your own interest, _do_ desist from upside-down-quoting.
That seems to be a matter of opinion. I don't have a preference, but I
have read some who are of the opinion that quoting should not be at the
top because they have already read it once, and it should be quoted
below, footnote style. But If quoting at the top is the norm for this
group - I'm happy with that.
>good luck.
Thanks - I probably need it ;-)
--
Richard Jones, Leeds, UK
rajones (at) mail.com
or remove NO_UCE* from 'reply-to' address
------------------------------
Date: Mon, 15 May 2000 12:29:49 -0500
From: "Tim" <tcuffel@exactis.com>
Subject: Garbage Collection
Message-Id: <C6XT4.2932$58.21707@den-news1.rmi.net>
I just did some work on garbage collection, and decided to
take a look at what Perl does.
The docs say simple reference counting with mark and sweep
on thread termination. They also say better garbage collection
is planned, but give no details.
Is there something in the works? I did a little digging, but
came up with nothing. I would be very interesting in finding
out what Perl is up to.
-T
------------------------------
Date: Sun, 21 May 2000 17:39:13 +0100
From: "A Pietro" <apietro@my-deja.com>
Subject: Global variables to apply to multiple Perl scripts
Message-Id: <8g93fo$psj$1@sshuraab-i-1.production.compuserve.com>
I have written a small program consisting of 8 or 9 Perl scripts. The
scripts were developed on my home Linux computer. But, in order that they
may be used on other computers, with different directory structures, I have
included a line at the start of many of the scripts, like:
##Change this for your particular installation
$INSTALL_DIR='/home/development/test';
##************************************
So my scripts *can* be run on other machines, *but* the user will have to
edit 6 or so scripts.
Whats the best way round this?
I was thinking in terms of a central config file, which contained the
setting:
$INSTALL_DIR='/home/development/test';
Advantage -- the user would only have to change this one setting
Disadvantage -- I reckon I would need to parse the config file and get the
correct $INSTALL_DIR every time I ran a script...a subroutine &ParseConfig()
or similar would have to read the settings into an array, then pull out the
correct setting, prior to completing the rest of the script. That sounds
wasteful on processor time...
I'm looking for some way to have global variables available to all the
scripts. Is this possible in Perl?
Any tips welcomed.
AP
------------------------------
Date: Mon, 22 May 2000 01:14:53 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Global variables to apply to multiple Perl scripts
Message-Id: <8g958f$fh7$1@mawar.singnet.com.sg>
A Pietro <apietro@my-deja.com> wrote in message
news:8g93fo$psj$1@sshuraab-i-1.production.compuserve.com...
> I have written a small program consisting of 8 or 9 Perl scripts. The
> scripts were developed on my home Linux computer. But, in order that they
> may be used on other computers, with different directory structures, I
have
> included a line at the start of many of the scripts, like:
>
> ##Change this for your particular installation
> $INSTALL_DIR='/home/development/test';
> ##************************************
>
> So my scripts *can* be run on other machines, *but* the user will have to
> edit 6 or so scripts.
> Whats the best way round this?
There are several ways. For example, you can use the AppConfig module (get
it from CPAN). Or do it like the libnet modules (see Net::Config) - an
example below...
> I was thinking in terms of a central config file, which contained the
> setting:
>
> $INSTALL_DIR='/home/development/test';
>
> Advantage -- the user would only have to change this one setting
> Disadvantage -- I reckon I would need to parse the config file and get the
> correct $INSTALL_DIR every time I ran a script...a subroutine
&ParseConfig()
> or similar would have to read the settings into an array, then pull out
the
> correct setting, prior to completing the rest of the script. That sounds
> wasteful on processor time...
You can use "require" or "use" to pull in the values.
> I'm looking for some way to have global variables available to all the
> scripts. Is this possible in Perl?
Yes. Definitely.
> Any tips welcomed.
Here goes a simple example:
=== begin YourModule/Config.pm ===
package YourModule::Config;
use strict;
use vars qw(@ISA @EXPORT %Conf);
use Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(%Conf); # make %Conf globally accessible
%Conf = (
INSTALL_DIR => '/home/development/test',
DEBUG => 0,
OTHER_PARAM => '/bah/bah/black/sheep',
);
1; # remember to end with a TRUE value!
==== end YourModule/Config.pm ====
Subsequently, all your other scripts will:
use YourModule::Config;
and access the configuration parameters via:
$INSTALL_DIR = $Conf{INSTALL_DIR};
$DO_WE_DEBUG = $Conf{DEBUG};
When you need to change, just edit YourModule/Config.pm.
Got it?
Swee Heng
------------------------------
Date: Sun, 21 May 2000 16:01:49 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Is this the right behaviour for Net::SMTP/Cmd?
Message-Id: <392bf613.4016939@news.skynet.be>
Swee Heng wrote:
>I believe the same is true of sendmail. Which is strange, since the dot to
>end DATA has no preceding <CR><LF> and is thus not RFC compliant.
The RFC talks about "a dot on a line of it's own". There needn't be a
CRLF in front of it, if it's indeed the first thing you send. Otherwise,
there is no way to get a dot on a line of it's own except with CRLF in
front of it.
From RFC821, page 4:
SMTP indicates the end of the mail data by sending a line
containing only a period.
--
Bart.
------------------------------
Date: Sun, 21 May 2000 17:59:56 GMT
From: Bob Margulies <rsm@loop.com>
Subject: ISP for experimenting?
Message-Id: <392823B4.9A5D837B@loop.com>
I am interested in doing some server-side Perl programming. This would
require me to install a script in my directory on my ISP's site, which I
would then run from my Windows 98 computer. When I asked my ISP how I
might go about this, I was told to submit the script to them, and after
they inspected and approved it, they would install it for me.
Since I am only a beginner at this kind of programming, I expect it
might take many cut-and-try attempts before I had just what I wanted.
This would be very inefficient for both the ISP and for me.
Is there a way for me find an ISP that would allow me to experiment with
Perl scripting?
------------------------------
Date: Sun, 21 May 2000 17:39:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: perl to lunch "Save As" browser window ???
Message-Id: <Pine.GHP.4.21.0005211620240.27796-100000@hpplus01.cern.ch>
I'm x-posting this and setting f'ups, because its relevance to Perl
is tenuous at best...
Most WWW readers will already be well familiar with this issue, and
a check of the WDG FAQ item that you cited will set the scene...
On Sun, 21 May 2000, Bart Lateur wrote:
> Here are a few URL's for you to chew on:
>
> http://www.ex.ac.uk/its/webmatters/htmlreference/faq.html#force-download
I recognise that! It's a copy of the WDG's HTML FAQ at
http://www.htmlhelp.com/faq/html/ , specifically
http://www.htmlhelp.com/faq/html/media.html#force-download
(and it's a good answer)
> http://msdn.microsoft.com/workshop/essentials/webmen/webmen050498.asp#saveit
Well, it says:
Part of the difficulty has to do with the type of file you're trying
to get saved, and the rest of the difficulty has to do with the
clicking part.
Of course it would hardly seem polite to say to the questioner: "the
major part of your problem is that you don't understand how the WWW is
meant to work, so you're trying to achieve something that the web
deliberately doesn't want you to do. And the rest of your problem is
that MSIE disregards the WWW specifications when it feels like it."
> http://support.microsoft.com/support/kb/articles/q182/3/15.asp
This is in regard to conformance with RFC2183, which is about MIME
support in "messages" and the Content-disposition: header.
However, refer to the HTTP/1.1 spec, RFC2616, particularly
http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1
which discusses the security implications of honouring this header,
which is not formally part of HTTP.
The whole design of the WWW is based on the server telling the client
honestly what kind of resource is being made available to them (rather
than trying to "force" them into doing anything specific), and the
suitably-clued user deciding on the basis of that information, what
they want to do with it: open it in the browser, fire up a helper
application, save it to disk, or whatever _they_ deem appropriate.
In my not so humble opinion, it seems to me that anyone who is so dumb
as not to know how to tell their browser to save a resource to disk,
should have no meaningful use for anything retrieved from the 'net in
the first place. Until they've got that minimal level of expertise to
know how to deal with downloaded resources, one ought not to tempt
them - and the recent world-wide email worm disaster is only a small
token of what _could_ be achieved in analogous ways. One would be
practically handing the user a grenade with the pin out, and no
operating instructions.
cheers
------------------------------
Date: Sun, 21 May 2000 17:53:07 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: perl to lunch "Save As" browser window ???
Message-Id: <Pine.GHP.4.21.0005211746330.27796-100000@hpplus01.cern.ch>
On Sun, 21 May 2000, Sergey Gribov wrote:
> > You can't force a browser to engage a specific behaviour
> > determined by you from the server-side.
> Actually you can do this pretty easily. All you need to do is in
> your CGI script instead of generating 'text/html' content type,
> to generate other appropriate type (e.g. 'application/x-zip-compressed')
Right, and my browser will then fire up the appropriate application
for uncompressing it.
>> and browser will know, that instead of treating you output as HTML
> it should just save it.
Browsers don't "know" anything, beyond what they've been configured to
do.
> Something like this will work:
> print "Content-Disposition: attachment ; filename=$my_filename\n";
> print "Content-type: application/x-zip-compressed\n\n";
> print $buffer;
Right, I just tried that: the browser announced "Opening foo.bar using
Wiz.exe". (As I knew it would).
> - this will ask browser to open 'Save As' dialog and try to save $buffer
> as a file with name $my_filename.
Will it? You can't know.
------------------------------
Date: Sun, 21 May 2000 08:55:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <392806DD.6A0C6C4C@stomp.stomp.tokyo>
Sue Spence wrote:
> I submit that this is not helpful to people, yet your
> introduction to your code was highly confident.
> How about coming back with code that will
> compile, run and provide the right answer?
I submit you don't know how to run a Perl program.
As it is, I tested this no less than twenty to
twenty-five times. Works perfect without failure.
I test all of my code, harshly, before posting,
knowing some of you less-than-skilled people will
be all over it like flies on fresh mule manure.
Godzilla!
------------------------------
Date: Sun, 21 May 2000 16:01:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <392af436.3539971@news.skynet.be>
Andrew N. McGuire wrote:
>while (<DATA>)
>{
> print "$1\n"
> if m|^Rating: \(1-10\) (\d*?\.*[05]*)</p><!--.*?-->|;
>}
Too specific to my taste.
m|Rating: *\(1-10\) *([\d\.]+)| and print "$1\n";
--
Bart.
------------------------------
Date: 21 May 2000 17:10:24 GMT
From: Intergalactic Denizen of Mystery <Tbone@pimpdaddy.com>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8g95a0$40b$1@news.enteract.com>
nospam@devnull.com writes:
>In article <8g8665$288s$1@news.enteract.com>, Tbone@pimpdaddy.com wrote:
>
> | godzilla@stomp.stomp.tokyo writes:
> | >Why bother with a possibly error prone fancy regex when
> |
> | Not your best effort. Think of something new or shut the fuck up.
> |
>
>yo, jackass.. say hello to my little friend --> *plonk*
*applause*
------------------------------
Date: Sun, 21 May 2000 16:54:55 GMT
From: mosher@amdocs.com (Dr. Smith)
Subject: REGEXP newbie question
Message-Id: <392812f4.39129365@sointnews>
Hi,
Can anyone give me a nice regular expression that will give a match,
only if the string entered is a leagal UNIX user name?
Thanks a lot,
Dr. Smith
------------------------------
Date: Sun, 21 May 2000 16:01:41 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regular expression ?
Message-Id: <39280865.476e$155@news.op.net>
In article <391C80D9.7B2F9CB7@bigfoot.com>,
=?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com> wrote:
>Please stay with standard 7-bit ASCII.
>
>
>--
> Thorbjרrn Ravn Andersen "... plus .. Tubular Bells!"
״H, the irony.
ררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררר
ררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררר
ררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררר
ררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררררר
------------------------------
Date: Sun, 21 May 2000 16:16:18 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regular expression ?
Message-Id: <39280bcd.4806$347@news.op.net>
In article <391C3E41.CE517A49@stomp.stomp.tokyo>,
Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
>Jeff Zucker wrote:
>> ...And one should use "my" instead of "local".
>
>
>Seven very good reasons to use local over my, and
>some interesting notes on slurping being more
>efficient than use of while.
>
>http://www.plover.com/~mjd/perl/local.html
>
>
>Do your homework before responding to my articles.
The article presents seven reasons why you might want to use local,
and none of them apply in your example. You are not calling a
function which requires dynamic scope. You are not saving a temporary
value for a Perl special variable. You are not aliasing a glob. You
are not generating a dynamic filhandle. You are not using perl4.
Do you own homework. Contrary to what you said, that article does not
contain ''seven very good reasons to use local over my.'' It contains
zero. If both 'my' and 'local' will work, you should use 'my'. It
specifically offers the advice that you should use local *only* when
my doesn't apply:
| Useful uses for local fall into two classes: First, places where you
| would like to use my, but you can't because of some restriction, and
| second, rare, peculiar or contrived situations.
| ...
| Always use my; never use local unless you get an error when you try
| to use my.
You should have used 'my' instead of 'local'.
------------------------------
Date: 21 May 2000 11:57:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Resource Temporarily Unavailable
Message-Id: <8g8fea$gj0$1@orpheus.gellyfish.com>
On Fri, 19 May 2000 23:41:11 -0700 Gabe wrote:
> My program is dying after trying to connect. $! gives Resource Temporarily
> Unavailable. Can anyone see why it's dying with that error?
>
> my $driver = "mysql";
> my $database = "cremeco_com";
> my $dsn = "DBI:$driver:database=$database";
>
> my $dbh = DBI->connect($dsn, $user, $password) || die &error;
>
That is because that was the last OS error - a problem with DBI->connect will not
set $! and you should use $DBI::errstr instead to get the database error (or
set the RaiseError option in your connect().
/J\
--
Marge, I'm going to miss you so much. And it's not just the sex. It's
also the food preparation.
--
fortune oscar homer
------------------------------
Date: Sun, 21 May 2000 18:42:08 +0200
From: Penpal International <ppi@searchy.net>
Subject: Sendmail problem!
Message-Id: <392811E0.983E8A0B@searchy.net>
Hi!
I have a little problem with sending mail with sendmail. I have this
script:
$mailprog = "/usr/sbin/sendmail";
foreach $line(@email) {
$line =~ s/\n//g;
open (MAIL, "|$mailprog -t");
print MAIL "To: $line\n";
print MAIL "From: webmaster\@searchystats.com(SearchyStats)\n";
print MAIL "Subject: SearchyStats News & Updates\n";
print MAIL $message;
close (MAIL);
print "($count/$total): $line -> Success!\n";
$count++
}
Every time it changes searchystats.com to the hostname my machine is
running on. How can I force it to send the right address at the From
field?
--
Penpal International
http://ppi.searchy.net/
ppi@searchy.net
------------------------------
Date: Sun, 21 May 2000 17:05:53 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Sendmail problem!
Message-Id: <B54D8FB4.46D4%elaine@chaos.wustl.edu>
in article 392811E0.983E8A0B@searchy.net, Penpal International at
ppi@searchy.net quoth:
> Every time it changes searchystats.com to the hostname my machine is
> running on. How can I force it to send the right address at the From
> field?
Try http://search.cpan.org/search?dist=Mail-Sendmail
e.
------------------------------
Date: Sun, 21 May 2000 16:10:36 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: SSI in Perl Script ?
Message-Id: <8g8u9o$enp$1@neptunium.btinternet.com>
http://www.apache.org
------------------------------
Date: Sun, 21 May 2000 16:33:00 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: the use of $_
Message-Id: <39280fbb.4889$64@news.op.net>
In article <x7og62fb1i.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
>so it is not bigotry, but a proper understanding of why my is better for
>all cases BUT these 7 special ones. having special cases means that my
>is meant to be used and not local unless local is needed.
It's really only 5 reasons, because if you look at the table of
contents, you'll see:
1. Special Variables
2. Localized Filehandles
3. The First-Class Filehandle Trick
4. Aliases
5. Dynamic Scope
6. Dynamic Scope Revisited
7. Perl 4 and Other Relics
2 and 3 are really the same thing, and 5 and 6 are certainly the same
thing. But I had promised an article on `seven useful uses of local'
and then when some of the uses I had thought of didn't work out, I had
to figure out where to get some more.
Reason 1 is still a good reason. It's probably the *only* good reason
to use local.
Reasons 2-3 have been pretty much obsoleted with the release of perl
5.6.0 because you can now say
open my $fh, $file;
Reason 4 is really abstruse, and Sarathy's `Alias' module takes care
of most of its useful uses, in a better way, without needing to use
`local'.
Reasons 5-6 were never good. The example in section 5 is a clever
hack, and you could live your whole life and die happy without ever
usnig it. Section 6 is about how to work around a misdesigned library
function that uses a global variable. The right approach in the
latter case is to fix the broken library function, not to use local.
Reason 7 is if you're stuck with perl 4. ''I am stuck with perl 4''
is never *good* reason to do *anything*, except maybe to cut your
wrists or something.
So we have three obsolete reasons, one clever advanced hack, one very
abstruse task that can be accomplished with a nice module, and one
good reason. But if I had named the article ``Six useless and
obsolete uses of local'' Jon probably wouldn't have bought it from me.
------------------------------
Date: Sun, 21 May 2000 10:20:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: the use of $_
Message-Id: <39281AD2.8B439E31@stomp.stomp.tokyo>
Mark-Jason Dominus wrote:
Previous dicussions center on use of "local" ..
(snippage)
> Reason 7 is if you're stuck with perl 4. ''I am stuck with perl 4''
> is never *good* reason to do *anything*, except maybe to cut your
> wrists or something.
Perl 4 is still currently shipped with some
operating system packages and, Perl 4 concerns
are posted here at times. Perl 4 is still quite
viable and of concern to many. To shun posters
here for use of Perl 4 or to shun those who are
stuck with Perl 4, is most illogical, unrealistic
and perhaps, an act of technological bigotry.
Skilled and imaginative programmers routinely
make use of Perl 4 to write great programs and,
have no need for copy and paste Perl 5.
Perl 4 is the foundation of Perl 5, yes?
> So we have three obsolete reasons, one clever advanced hack, one very
> abstruse task that can be accomplished with a nice module, and one
> good reason. But if I had named the article ``Six useless and
> obsolete uses of local'' Jon probably wouldn't have bought it from me.
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlsub.html#Temporary_Values_via_local_
=)
Godzilla!
------------------------------
Date: Sun, 21 May 2000 09:39:33 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Untaint URL character class
Message-Id: <39281145.5C17DF86@stomp.stomp.tokyo>
bbfrancis@networld.com wrote:
> I'm trying to untaint URL data for 'a send a link' CGI script, but I'm
> unsure of all the leagal characters that can be used in a URL.
This character set will make for a good
beginning point for hyperlinks:
(http://[\-~A-Za-z0-9_/\.]+)
...and this set, for 'mailto' type links:
(mailto:[@-A-Za-z0-9_/\.]+)
These two will work well for graphics
in a .gif or .jpg type format:
(http://[\-~A-Za-z0-9_/\.]+\.jpg)
(http://[\-~A-Za-z0-9_/\.]+\.gif)
There are, of course, some obscure exceptions
which may need to be added to each. Rest assured
some will jump and down, pull their hair and
scream about those exceptions. Ignore their
screaming but make note of their exceptions,
if you think you need those exceptions.
I will point out, if you think a query string
might show up at your site, you will need to
add a question mark (?), an ampersand (&) and
and equals character (=) to catch a query string.
Personally, I have enjoyed very good success with
those character sets for quite a few years. There
are times I do make minor adjustments to compensate
for those oddball rare exceptions.
Be sure to review basic security issues. You will
be allowing through a few characters which can be
combined for trickery. Quite rare with these sets
but they do exist, ../ is one of concern. Having
your program watch for a match of certain combinations
effectively defeats these possible problems.
Here is a link with great basic information
on what you might need to consider. There are
several pages at this easy-to-read site which
well covers basic security needs:
http://www.eekim.com/pubs/cgibook/ch09/0902.html
Godzilla!
------------------------------
Date: 21 May 2000 17:34:23 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Untaint URL character class
Message-Id: <8g936f$h4s$1@orpheus.gellyfish.com>
On Sun, 21 May 2000 04:24:30 GMT bbfrancis@networld.com wrote:
> I'm trying to untaint URL data for 'a send a link' CGI script, but I'm
> unsure of all the leagal characters that can be used in a URL.
Any characters can be part of a URL as long as they are appropriately encoded.
You will however want to ask in comp.infosystems.www.authoring.cgi as this is not
specific to Perl.
/J\
--
Marge, would you please tell Bart that I would just like to drink a
glass of syrup like I do every morning?
--
fortune oscar homer
------------------------------
Date: 21 May 2000 15:54:38 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: valid email address
Message-Id: <8g90ru$82q$1@newsflash.concordia.ca>
In article <392792B7.884AC4FC@momsathome.on.ca>,
Jennifer <webmaster@momsathome.on.ca> wrote:
>> Please don't yell at me. [cringing]
Ugh. I hate it when people are reduced to cringing because
they know someone's going to give them knee-jerk responses.
For some reason the email-address question produces more
knee-jerk responses than any other.
>> I've done searches on deja.com and I've read perlfaq9. I know
>> that you can't test for a valid address with a regexp nor can you
>> really check for valid syntax, but what I want to know is it ok
>> to check for something that is definitely invalid syntax?
In my opinion, yes. Lots of people mistype or don't seem to know
that "joe" isn't a good enough email address, for a remote site.
In practice you are checking for...
A valid machine name or IP: nslookup. You might want to handle cases
like "joe@dept" meaning "joe@dept.yourdomain.com". nslookup should
handle that. If their machine is temporarily unreachable, you might
have a problem.
preceded by a @
preceded by something. You can't know what's before the @, you would
assume it can't contain other @'s, but RFC822 actually allows them
in certain cases. Lots of weird addresses are deliverable.
>I'm still very weak on regexp, but this is what I came up with.
>Anything wrong with this?
>/.+@[a-zA-Z0-9\.-]{2,}\.[a-zA-Z]{2,}$/
If you really want to use regexes, here's some ideas, not very
well tested:
my $FF = qr/([01]?\d\d?|2([0-4]\d|5[0-5]))/; # matches 0-255
my $dotquad = qr/$FF(\.$FF){3}/;
my $domain = qr/([a-z0-9-]+\.)*[a-z]+/i; # must be fully qualified
# the last bit might be limited to known TLDs... an exercise
# for the reader. :)
my $email = qr/^.+@($domain|$dotquad)$/; # does not validate, merely
# rejects obviously wrong stuff.
Howls of protest from the audience. Okay, let's actually try
to accomodate the 0.001% of the public that might try something like
"joe @ foo . com" or include comment fields.
To be a little more correct (and the regexes I typed above may
not be totally up to snuff -- I need sleep) you could use a
regex written by Jeffrey Friedl which will match addresses more
or less in the manner of RFC 822.
http://www.cpan.org/modules/by-authors/Tom_Christiansen/scripts/ckaddr.gz
Finaly, the reliably ingenious Abigail has written a module which
uses Parse::RecDescent to check addresses against RFC 822. Please
forgive me if this module is not meant to be released, it
only seems to be available in her personal CPAN directory under
RFC::RFC822::Address.pm. It's slow but it seems to work, although
the test script shows it misses a few cases. Running the test script
with --debug shows just how insanely complex the spec is.
--
Neil Kandalgaonkar
neil@brevity.org
------------------------------
Date: Mon, 22 May 2000 01:57:51 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: valid email address
Message-Id: <8g97op$ch5$1@mawar.singnet.com.sg>
Jennifer <webmaster@momsathome.on.ca> wrote in message
news:39278C26.ECE3C6F3@momsathome.on.ca...
> Please don't yell at me. [cringing]
i won't.
> I've done searches on deja.com and I've read perlfaq9. I know
> that you can't test for a valid address with a regexp nor can you
> really check for valid syntax, but what I want to know is it ok
> to check for something that is definitely invalid syntax?
>
> I'm thinking that if it isn't any_char@any_two_char.any_two_char
> that it isn't valid syntax. I know I have filled out forms and
> forgot the .com. I just want to catch the stupidest of mistakes
> and hopefully narrow down the bad addresses that make it through.
>
> If this is correct, can someone offer a regexp to check for it?
i have no regexp. but since no one mentioned it, i just want to say that
there is an email address validation module that might be useful. go to:
http://cpan.valueclick.com/modules/by-authors/Abigail/
and look for Abigail's RFC_RFC822_Address-1.4.tgz. I don't know why it did
not appear on search.cpan.org but it is there. read about it on this ng a
long time ago.
swee heng (see? i didn't yell :)
------------------------------
Date: Mon, 15 May 2000 13:51:17 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <391fff59.64553886@news.rmi.net>
Silly ActiveSate perl 5.6 install bug.
Windows has many vestiges of its command-line DOS heritage. One of the is that
if you change the PATH stsement before Windows finishes loading, as ActiveState
5.6 does, Windows will not be able to find WIN.COM. Manually add that perl
directory to your path or as Stwe says, change it to
SET PATH=C:\Perl\bin;%PATH%\
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Thu, 18 May 2000 05:23:58 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: What's this line which Perl added to AUTOEXEC.BAT?
Message-Id: <39237c70.1273226@news.rmi.net>
On Wed, 17 May 2000 09:03:56 -0700, bjanko <waldo700NOwaSPAM@aol.com.invalid>
wrote:
>Despite the doubts of some, my computer did not boot with merely
>SET path c:\perl\bin and now it boots fine.
Good. Very good. Now...
Don't consider what follows a mere quibble, but remember that Win9x is really
extended DOS, a command line oriented OS (like *nix, unlike Apple System N),
with WIN.COM responsible for kicking DOS into GUI mode.
What losing c:\windows from your path did was NOT preventing the computer from
booting. It merely prevented DOS from loading Windows behind your back, so to
speak.
Didn't you at least wind up with a DOS prompt? And one that could have allowed
you to run EDIT to fix that AUTOEXEC.BAT error?
You know the 'Restart in DOS mode' shutdown item in Win9x? Think about that
one.
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
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 3112
**************************************