[11524] in Perl-Users-Digest
Perl-Users Digest, Issue: 5124 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 12 23:07:32 1999
Date: Fri, 12 Mar 99 20:00:16 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 12 Mar 1999 Volume: 8 Number: 5124
Today's topics:
Re:
Re:
Active perl <bgarrett@hamilton.net>
Re: Are negative array indeces allowed? (Larry Rosler)
Re: Are negative array indeces allowed? (Abigail)
Re: Can Perl do this? (Steve Leibel)
Re: CGI Images (brian d foy)
Re: command-line CGI (Larry Rosler)
Re: does perl discourage obfuscated code? (was Re: Perl (Larry Rosler)
Re: Exporter question <sternji@mail.northgrum.com>
Re: flock / sysopen / open confusion <zenin@bawdycaste.org>
Re: Multiple Users Corrupting File (Alastair)
Re: Multiple Users Corrupting File <palincss@his.com>
Re: Multiple Users Corrupting File <cassell@mail.cor.epa.gov>
Re: Nevermind...found it <eric.weiss@central.sun.com>
Re: Perl acting different when run as CGI? (brian d foy)
Re: remote ftp and exec from NT to Unix <bill@fccj.org>
Re: SSI query <jglascoe@giss.nasa.gov>
Testing for empty scalar ($ARGV[0]) <eric.weiss@central.sun.com>
Re: The Meta-problem: helping others with Perl problems <jglascoe@giss.nasa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Mar 1999 21:24:33 -0500
From: in@after.noon (Friday@Dragnet)
Subject:
Message-Id: <in-1203992124340001@1cust19.tnt6.syracuse.ny.da.uu.net>
James,
I mistakenly thought that you purposely would have had me delete 1500
files by changing "rename" to "unlink" but after correspodning with you by
e-mail, I sincerely believe it was an honest mistake that I overacted to,
and I sincerely appologize to you for the grief I may have caused you.
Sincerely,
Bob Langdon
------------------------------
Date: Fri, 12 Mar 1999 21:25:23 -0500
From: in@after.noon (Friday@Dragnet)
Subject: Re:
Message-Id: <in-1203992125240001@1cust19.tnt6.syracuse.ny.da.uu.net>
In article <bingdo19-ya02408000R1203991142540001@news.alt.net>,
bingdo19@earthlink.net (Bob Langdon) wrote:
> Special thanks to James Tolley <jamesht@idt.net> who e-mailed me to share:
>
> >> Glad to hear it's working for you. But if you want to improve it
> >> slightly, use unlink() instead of rename().
> >
James,
I mistakenly thought that you purposely would have had me delete 1500
files by changing "rename" to "unlink" but after corresponding with you by
e-mail, I sincerely believe it was an honest mistake that I overacted to,
and I sincerely appologize to you for the grief I may have caused you.
Sincerely,
Bob Langdon
------------------------------
Date: Fri, 12 Mar 1999 11:24:51 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re:
Message-Id: <MPG.115309e0feccbc7798972c@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <bingdo19-ya02408000R1203991142540001@news.alt.net> on Fri,
12 Mar 1999 11:42:54 -0400, Bob Langdon <bingdo19@earthlink.net> says...
> Special thanks to James Tolley <jamesht@idt.net> who e-mailed me to share:
> >> Glad to hear it's working for you. But if you want to improve it
> >> slightly, use unlink() instead of rename().
> >
> > instead of:
> >
> >>rename ("$dir/$file" , "$dir/$1") or die "Couldn't rename $dir/$file. $!\n";
> >
> > use:
> >
> > unlink("$dir/$file") or die "Couldn't unlink the file $dir/$file: $!";
>
> Thanks James!
Thanks for what exactly -- for throwing away your data file instead of
changing its name?
Perhaps your thanks were facetious or sarcastic.
By the way, you have several strange characters in your Subject line (in
this post and in your identical posting of these same thanks under a
different subject).
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 12 Mar 1999 20:55:58 -0800
From: Bill Garrett <bgarrett@hamilton.net>
Subject: Active perl
Message-Id: <36E9EFDA.E390B491@hamilton.net>
Finally, I have got a new computer with win 98 instead of win 3.x
So, if I download active perl is that all I need to start writing,
editing, and debugging perl scripts. or do I still need some kind of
shell access?
Jason
------------------------------
Date: Fri, 12 Mar 1999 07:48:57 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Are negative array indeces allowed?
Message-Id: <MPG.1152d739912328b298972b@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36E92390.308C6E84@gte.com> on Fri, 12 Mar 1999 09:24:16 -
0500, John Chambers <john.chambers@gte.com >says...
> Sam Holden wrote:
> > On 12 Mar 1999 12:43:27 +0100, Alex Farber <eedalf@eed.ericsson.se> wrote:
> > >I have just discovered that perl -e '@x = qw (a b c); print $x[-3]'
> > >prints "a" on my Solaris workstation (perl 5.004_04). So, is a
> > >negative array index allowed? Amazing, I haven't ever read about it
> > >in the 5 perl books I have or in "perldoc perldata"... When was it
> > >introduced? Can I rely on it now?
...
> > Well it does in 5.005 under linux, and 5.002 under Solaris. So I assume
> > it didn't disappear in between.
>
> Jeez; it'd have been a lot less typing to simply answer the question:
>
> No.
I think you mean 'Yes.' (The question was "Can I rely on it now?")
> (Perhaps it would also help the supplicant^Wposter to observe that
> negative subscripts work just fine with hashes; aka associative
> arrays. Of course, these beasties don't behave quite the same
> as plain vector-style arrays, and performance isn't as good. But
> in many programs, you can get the desired effect by simply using
> {} rather than [] around the array subscripts.)
I am thoroughly confused by what you are saying here.
The point of the negative array index is that in an array with three
elements, $a[0] and $a[-3] refer to the same element, and $a[1] and
$a[-2] refer to the next element. This is the 'desired effect'.
But with a hash of no matter how many elements, there can be no
relationship between any elements based on the arithmetic value of the
hash index. They are treated as strings, and $h{0} is $h{'0'}, while
$h{-3} is $h{'-3'}, and ne'er the twain shall meet, no matter how many
elements are in the hash.
I am thoroughly confused by what you are saying here.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 13 Mar 1999 02:35:56 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Are negative array indeces allowed?
Message-Id: <7cciuc$1vj$1@client2.news.psi.net>
Eric The Read (emschwar@mail.uccs.edu) wrote on MMXX September MCMXCIII
in <URL:news:xkfn21ikzyr.fsf@valdemar.col.hp.com>:
<> John Chambers <john.chambers@gte.com> writes:
<> > (Perhaps it would also help the supplicant^Wposter to observe that
<> > negative subscripts work just fine with hashes; aka associative
<> > arrays.
<>
<> Er, can hashes actually have negative subscripts? That same first
<> paragraph of perldata says they're indexed by string. Unless you mean
<> that you can use "-1" as an index to a hash, which is true enough, I
<> suppose.
Indexed by string indeed. And given that Perl automagically translates
number to strings, and strings to numbers, the answer is "yes".
Of course, there's not "begin" or "end" in a hash, so the meaning
of "-1" you have with array indexing doesn't exist with hash indexing.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Fri, 12 Mar 1999 18:06:22 -0800
From: stevel@coastside.net (Steve Leibel)
Subject: Re: Can Perl do this?
Message-Id: <stevel-1203991806250001@192.168.100.2>
In article <36E910B6.E223DF1E@hkusua.hku.hk>, soclc@hkusua.hku.hk wrote:
> Gentlemen,
>
> Can a Unix server remotely execute a Windows 95 program (with command
> line parameters) residing over a TCP network with Perl?
>
To do this you need to go to TUCOWS or some other shareware site and
install a telnet server on the win32 machine. Then use the Net::Telnet
module or code your own telnet interface (for example by using the Chat
package to control the local telnet client).
Another way to do this is to write a little server program on the win32
machine that listens on a port and executes programs in response to
commands from the client. Then you custom-code the client, designing your
own application protocol between client and server.
The advantage of the former approach is that telnet is standard and you
don't have to write any server code. The advantage of the latter approach
is that you get more precise control and reliablility, since you can
implement a detailed protocol that allows reporting from the server back
to the client of any error conditions etc.
Steve L
stevel@coastside.net
------------------------------
Date: Fri, 12 Mar 1999 20:55:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: CGI Images
Message-Id: <comdog-ya02408000R1203992055220001@news.panix.com>
In article <36E86AEB.35B1@nyct.net>, Rajan Alexander <raj@nyct.net> posted:
> I saw a CGI based database which allowed the upload of local images to
> the site. Does anyone know how this is accomplished or where I may
> obtain more information?
perldoc CGI
look for the section on file upload.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Fri, 12 Mar 1999 11:32:52 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: command-line CGI
Message-Id: <MPG.11530bc195a6774698972d@nntp.hpl.hp.com>
In article <83k8wm3bh6.fsf@vcpc.univie.ac.at> on 12 Mar 1999 17:43:17
+0100, Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> says...
> Re: command-line CGI, Dave <dave@peon.oit.umass.edu>
> said:
>
> Dave> I'm writing some CGI programs for work, and I
> Dave> would like to be able to test them from a
> Dave> command line, rather than having to test them
> Dave> on the web. Is there any way to simulate the
> Dave> QUERY_STRING from the command line? Thank you
> Dave> very much.
>
> This is trivial (sort of) with CGI.pm, q.v.
And it is trivial (completely) without CGI.pm. Just use 'set' or
'setenv' or whatever command is appropriate for your command
interpreter, to set the environment variable QUERY_STRING; then invoke
the CGI program from the command line.
To me, that seems like a lot less work than learning a new language
(sufficiently dense to warrant a 300-page book about it!), and rewriting
your application to use it, and waiting for it to load on each CGI
invocation, and ...
But my view on this subject is not Politically Correct around here.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 12 Mar 1999 12:15:23 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <MPG.115315b9626681e598972e@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <199903121511.IAA29577@asarian-host.org> on Fri, 12 Mar 1999
16:09:20 +0100, Mark <admin@asarian-host.org> says...
> Although Perl does not in and by itself discourage or encourge anything, the
> means it provides to express yourself, like any language, largely determines
> whether we regard the things we want to do as obfuscate or lucid.
>
> But I think there are two scales here that we should consider: "useless to
> powerful" vs. "terse and legible". You cannot make a statement about a value
> on one of the scales, without relating it to the other too. For instance,
> very powerful instructions tend to be more terse than easier ones. Since
> Perl is extremely powerful, it can pack a multitude of operations into a
> single line. Now, you can look at this from the "terse and legible" scale,
> and conclude that Perl promotes obfuscate coding. But by the same measure,
> seen from the "useless to powerful" scale, you can just as easily state that
> Perl promotes powerful coding. My point being still, that you cannot look at
> one very dense line of code and call it obfuscate just because your mind is
> being dazzled by the amount of things that happen in this one line: one is
> the result of the other. In fact, perl regexs are so powerful that to the
> newbie mind they will appear to be magical. But if you were to "unroll" such
> a powerful regex and rewrite it in C, your code would grow by an order of
> magnitude and would not necessarily be more clear. The way a C programmer
> has to use >, <, --, and ++ signs to even get a simple loop going without
> un- or overflowing, is not encouraging anything, but only discouraging usage
> of the entire language itself. Not dissing C or anything, but I have found
> Perl to be the most refreshing thing since ice-cream.
It is very seldom that I respond to a submission and repost the whole
thing, but I can't find a single idea in your observations that I would
want to cut out. (Though I did find 'get a simple loop going without
un- or overflowing" to be a bit daunting. 'unflowing'? :-)
As a long-time C 'guru' and now as a Perl Master (as attested by a
freebie evaluation whose URL was posted here earlier this week :-), I
can attest to the order-of-magnitude differences in verbosity. I have
implemented similar string-manipulating code in a CGI C program (that
runs often and quickly) and a command-line Perl program (that runs
seldom and quickly enough), and am amazed at how much more concise --
and as a result how much clearer -- the Perl code is.
In regard to terseness vs. legibility, some of the stuff posted here
(usually by newbies, strangely enough) is terse to the point of
unreadability:
$x=(@{f($y+3/$z,4,$q)})[0,3,7];
when a little 'air' around the tokens makes it much plainer:
$x = ( @{ f($y + 3 / $z, 4, $q) } )[0, 3, 7];
On the other hand, I believe that the fewer the tokens used to express
an algorithm, the better. (In other words, make maximal use of the
powerful capabilities of an expressive language.) I would far prefer to
write a functional:
print map f($_) => sort grep /foo*bar/ => @array;
(reading the fancy commas as 'applied to') than to write explicit loops,
without even using the default iterator (to avoid 'obscurity'):
my @temp;
foreach my $element (@array) {
push @temp, $element if $element =~ /foo*bar/;
}
foreach my $element (sort @temp) {
print f($element);
}
Concern that maintainers might not understand the terser code is
misplaced. Let them learn the language rather than forcing me to speak
pidgin (or 'baby talk', as the Blue Camel puts it).
> - Mark
>
> System Administrator Asarian-host.org
>
>
>
>
>
>
> --
> For more information about this posting service, contact:
>
> help@asarian-host.org -- for info about our services
> admin@asarian-host.org -- for the server's administrator
> nclark@asarian-host.org -- for our PR manager
> irchelper@asarian-host.org -- for help on irc matters
>
> If you want an anonymous account, visit our sign-up page:
>
> http://asarian-host.org/emailform.html
Usenet propriety is to limit .sigs to four lines after the cut line. As
System Administrator for your site, surely you can deal with that (and
with all the air above the .sig).
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 13 Mar 1999 01:54:10 GMT
From: "James M. Stern" <sternji@mail.northgrum.com>
Subject: Re: Exporter question
Message-Id: <36E9C542.4E400EE2@mail.northgrum.com>
Phil R Lawrence wrote:
>
> I normally use modules in an oo style, so I'm a little lost as to what my error
> is in the following. Can anyone help out? My test.pl can't see the hash in
> CASSENV.pl, it seems.
>
> ------------------------------------
> package CASSENV;
> use strict;
>
> use Exporter ();
> use vars qw( @ISA @EXPORT );
> @ISA = qw( Exporter );
> @EXPORT = qw( %CASSENV );
>
> my %CASSENV = (
> COMMDIR => '/u/path/a',
> OTHERDIR => '/u/path/b'
> );
>
> 1;
>
> [...]
You can't export a 'my' variable, only a package variable. Exporter
works its magic by manipulating the symbol table but a 'my' variable has
no symbol-table entry.
Declare %CASSENV so:
use vars qw(%CASSENV); # For strict's sake
%CASSENV = (
# ...
);
--
James M. Stern Northrop Grumman Corp. Hawthorne, CA
Opinions expressed above are not necessarily my employer's.
------------------------------
Date: 13 Mar 1999 03:09:34 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: flock / sysopen / open confusion
Message-Id: <921294830.900207@thrush.omix.com>
Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
: Zenin <zenin@bawdycaste.org> wrote:
:> And how would you suggest opening a file for reading and writing if
:> it doesn't already exist? -Hint: <+ will fail if the file does not
:> exist already.
:
: It will also fail if the actual file name doesn't being with a plus. ;)
:
: I think you meant +<. The plus has to be first.
Arg...you're right... :-/
Just more reason I never touch it. Sysopen() is far more reliable.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Sat, 13 Mar 1999 00:59:29 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Multiple Users Corrupting File
Message-Id: <slrn7eje73.5f.alastair@calliope.demon.co.uk>
Eric Patterson <epatterson@dese.com> wrote:
>Is there a way to combat this problem? Is there some way of restricting
>access to file that is currently open? Or perhaps another way alltogether.
Looks like you'd be best checking out file locking. See ;
perldoc -f flock
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: Fri, 12 Mar 1999 20:19:16 -0500
From: Steve Palincsar <palincss@his.com>
Subject: Re: Multiple Users Corrupting File
Message-Id: <36E9BD14.515946AF@his.com>
Eric Patterson wrote:
>
> I've run into a problem that I can't figure out. I hope someone here
> has an answer. I'm running a Perl bulletin board script that is accessible
> from the internet. Anytime two internet users execute the script within
> a small period of time files get corrupted. Specifically a file
> is opened and written too by the first user. The same file is opened
> by the second user before the first has finshed writing to the file. This
> is causing loss of data.
>
> Is there a way to combat this problem? Is there some way of restricting
> access to file that is currently open? Or perhaps another way alltogether.
>
flock
------------------------------
Date: Fri, 12 Mar 1999 17:23:40 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Multiple Users Corrupting File
Message-Id: <36E9BE1C.C5BAB32@mail.cor.epa.gov>
Alastair wrote:
> Eric Patterson <epatterson@dese.com> wrote:
> >Is there a way to combat this problem? Is there some way of restricting
> >access to file that is currently open? Or perhaps another way alltogether.
>
> Looks like you'd be best checking out file locking. See ;
>
> perldoc -f flock
Then you'll want to go check out some code that will show you how to use
such features. My guess is that you've never been exposed to flock before.
If I were you, I'd type that line Alastair suggested at your command prompt,
read the output, think about it a bit, then search out some Perl code to show
you how experts have implemented this. Try www.perl.org for starters. A
great site. And check out Randal Schwartz's Website, where he has copies of
his web design columns. His code ought to help you a lot.
David
--
David L. Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Fri, 12 Mar 1999 10:51:25 -0700
From: Eric Weiss <eric.weiss@central.sun.com>
Subject: Re: Nevermind...found it
Message-Id: <36E9541D.609437E2@central.sun.com>
Eric Weiss wrote:
>
> I was curious if there is a way to test for an empty scalar? Reason
> being, I have a script that I would like to have bail out if it detects
> no argument specified with the perl script command. For example, in ksh
> I've used something like: if ($scalar = "") then exit 1 fi
>
> Thanks,
>
> Eric
>
>
> --
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Eric Weiss
> ER-HW Support Engineer
> Sun Microsystems - Enterprise Services
> 500 Eldorado Blvd, Bldg 4
> Broomfield, CO 80021
> mailto:eric.weiss@central.sun.com
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Nevermind. It is the same as in ksh but it is:
if ($scalar eq "") {
exit 1;
Eric
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Eric Weiss
ER-HW Support Engineer
Sun Microsystems - Enterprise Services
500 Eldorado Blvd, Bldg 4
Broomfield, CO 80021
mailto:eric.weiss@central.sun.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Fri, 12 Mar 1999 20:53:09 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl acting different when run as CGI?
Message-Id: <comdog-ya02408000R1203992053090001@news.panix.com>
In article <36E9B0EC.C4C58EFF@giss.nasa.gov>, jglascoe@giss.nasa.gov posted:
> Andy Wallace wrote:
> > # Get the list of filenames...
> > #
> > # opendir(THISDIR, "../images");
> > opendir(THISDIR, "/home/andyw/public_html/images");
>
> Check the return value of all system calls ("opendir" is
> a system call). I suspect the browser, "nobody", doesn't
> have read access to "/home/andyw/public_html/images".
and don't use relative paths. the default working directory may
change with envrionments.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Fri, 12 Mar 1999 22:30:31 -0500
From: "Bill Jones" <bill@fccj.org>
Subject: Re: remote ftp and exec from NT to Unix
Message-Id: <36e9dbcf.0@usenet.fccj.cc.fl.us>
In article <36E8DC57.D9717D7F@ewh.uni-hannover.de>, Georg Raming
<raming@ewh.uni-hannover.de> wrote:
> Hi everybody!
>
> Can anyone please give me a quick example how to transfer files from
> NT-Workstation to a Unix-Workstation and execute a command there via a
> perl script on NT-Perl5.0?
>
> Thanks in advance!
The way you do it is via mail or a rewritten ftpd server...
Then you simply call a CGI on the Unix(?) side with LWP modules...
Pretty easy, but could be extremely easy to break security...
HTH,
-Sneex- :]
________________________________________________________________________
Bill Jones | FCCJ Webmaster | http://www.fccj.org/cgi/mail?webmaster
FCCJ | 501 W State St | Jacksonville, FL 32202 | 1 (904) 632-3089
Jacksonville Perl Mongers
http://jacksonville.pm.org
jax@jacksonville.pm.org
------------------------------
Date: Fri, 12 Mar 1999 19:54:07 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Mike Cardosa <fightace@gamestats.com>
Subject: Re: SSI query
Message-Id: <36E9B72F.7C3B55F2@giss.nasa.gov>
[courtesy copy of post sent to cited author]
Mike Cardosa wrote:
>
> Is it possible to use a query string while calling an SSI? I need this to
> work!
>
> EX:
> <!--#exec cgi="scriptname.cgi?this=should&work=nicely"-->
command line arguments work (or am I being to Unix-centric?)
<!--#exec cmd="/bin/echo hi hello biz" -->
Jay Glascoe
--
"Just say 'Narf!'."
--Pinky
------------------------------
Date: Fri, 12 Mar 1999 09:56:44 -0700
From: Eric Weiss <eric.weiss@central.sun.com>
Subject: Testing for empty scalar ($ARGV[0])
Message-Id: <36E9474C.2DBCF4D9@central.sun.com>
I was curious if there is a way to test for an empty scalar? Reason
being, I have a script that I would like to have bail out if it detects
no argument specified with the perl script command. For example, in ksh
I've used something like: if ($scalar = "") then exit 1 fi
Thanks,
Eric
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Eric Weiss
ER-HW Support Engineer
Sun Microsystems - Enterprise Services
500 Eldorado Blvd, Bldg 4
Broomfield, CO 80021
mailto:eric.weiss@central.sun.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Fri, 12 Mar 1999 20:15:47 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: The Meta-problem: helping others with Perl problems
Message-Id: <36E9BC43.EC717914@giss.nasa.gov>
hi,
Here's a copy of gnat's "Welcome" email.
---------- Forwarded message ----------
Date: Thu, 28 Jan 1999 20:00:07 -0700 (MST)
From: gnat@frii.com
To: jglascoe@giss.nasa.gov
Subject: WELCOME to comp.lang.perl.misc
Hello,
This email is automatically sent to every new poster to
comp.lang.perl.misc. You should only receive it once. My apologies
if the program contacts you twice, perhaps at two different accounts.
This is not a flame, only an attempt to help newcomers get the most
out of the newsgroup.
If you are an experienced Perl programmer who simply has not posted
before, or have inadvertently cross-posted to comp.lang.perl.misc, I
apologize for inconveniencing you with this message. Keep in mind
that it is intended to help inform newcomers and cut down on redundant
posts, which you then won't have to read. Some of the resources in it
may prove useful to you anyway, however.
Please look at the following tips, which will often answer your
questions without the need to post at all. Every post to the
newsgroup consumes the time and effort of readers all over the world,
and your cooperation is essential to make the newsgroup useful for
everyone.
Thanks!
* * *
1. Perl development has taken two courses: 5.004_05 is the latest
stable version, while 5.005_02 is the latest experimental version.
You can download them from
http://www.perl.com/CPAN/src/
(look in ftp://ftp.perl.com/perl/ for a list of FTP-based mirrors)
2. comp.lang.perl.misc is for questions on the Perl language. Try
comp.infosystems.www.authoring.cgi for questions on the CGI part of
CGI scripts. The two leading blocks of reusable code for CGI purposes
are CGI.pm, at
http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
and cgi-lib.pl, at
http://www.bio.cam.ac.uk/cgi-lib/
You might also want to check out libwww-perl at
http://www.linpro.no/lwp/
If you are having problems with a CGI script, look through
http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
3. Are you using the following?
#!/usr/bin/perl -w
use diagnostics;
use strict;
"-w" turns on all sorts of warnings about probable errors (see the
perldiag manpage), "use diagnostics" causes the "-w" warnings to be
explained in greater detail (with the explanations from the perldiag
manpage), and "use strict" generates compile and run-time errors for
certain unsafe variable, reference and subroutine constructs (see the
strict manpage)
4. Are you checking the return values from the functions built in to
perl? Most of the file and system functions set $! and have return
values that you can test thus:
open(PASSWD, "</etc/passwd") or
die "error opening /etc/passwd: $!\n";
$! will contain an error message that will give you more information
on where your program is going wrong. The perlfunc man page will give
you more information on the return values from functions.
5. Have you read the Perl FAQ? Many questions on sockets programming,
an important and common problem with Solaris, text manipulation and
the jargon of perl are answered in the FAQ. As well as being posted
regularly to comp.lang.perl.misc, the FAQ is on the web at:
http://language.perl.com/faq/
6. Have you read the man pages? Here are some subjects and the man
pages to look in:
Objects perltoot, perlref, perlmod, perlobj, perltie
Data Structures perlref, perllol, perldsc
Modules perlmod, perlsub
Regexps perlre, perlfunc, perlop
http://www.perl.com/CPAN/doc/FMTEYEWTK/index.html
(not a man-page but still useful)
Moving to perl5 perltrap, perl
Linking w/C perlxstut, perlxs, perlcall, perlguts, perlembed
The man page for "perltoc" provides a crude table of contents for the
perl man page set.
7. Have you looked at http://www.perl.com/ ? This is a great
online reference, with documentation, pointers to modules in the
Comprehensive Perl Archive Network (CPAN), articles on the inner
workings of many bits of Perl, and more.
7.5. Have you checked to see if a Perl module satisfies your needs?
Many reusable modules are available for immediate download and use.
See http://www.perl.com/CPAN/modules/00modlist.long.html for details.
8. Have you tried archives of Usenet? http://www.dejanews.com/
maintains an archive of postings to Usenet dating from March, 1995.
Be sure to include "Perl" in your search.
9. The latest version of the "Camel Book" ("Programming Perl"),
updated for version 5.003, is available from your bookstore or from
http://www.ora.com/
10. Remember, USENET newsgroups are based on the idea of mutual aid.
USENET only works if we put as much into it as we get out of it. Good
luck with your Perl work.
-Nathan Torkington, Perl mini-FAQ maintainer
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5124
**************************************