[8630] in Perl-Users-Digest
Perl-Users Digest, Issue: 2247 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 4 03:07:16 1998
Date: Sat, 4 Apr 98 00:00:51 -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 Sat, 4 Apr 1998 Volume: 8 Number: 2247
Today's topics:
Re: bitbucket for (,$b,,,$e,,)=split(/\,/,$string) (Martin Vorlaender)
Re: CGI-BIN: Link to other directories within a passwor <rootbeer@teleport.com>
Re: contexts: is there such a thing as array? (Spider Boardman)
Re: current week <sowmaster@juicepigs.com>
Re: Database sorting problem (Martin Vorlaender)
Re: Delete file on server! <rootbeer@teleport.com>
Re: Determining variable types <rjk@coos.dartmouth.edu>
Re: Diddling with search engines via CGI <rootbeer@teleport.com>
Re: eval with text files <rjk@coos.dartmouth.edu>
Re: File Renaming Problem (Please Help...) <rootbeer@teleport.com>
Re: How do I strip newlines from a var <rjk@coos.dartmouth.edu>
Re: Is there a "Newsgroup" for Newbies to Perl? <ljz@asfast.com>
Re: Is there a "Newsgroup" for Newbies to Perl? <rjk@coos.dartmouth.edu>
Re: Obfusticator (Abigail)
Re: Obfusticator <rjk@coos.dartmouth.edu>
Re: Perl Databases... <rjk@coos.dartmouth.edu>
Re: Ping (Peter Eisch)
Re: Ping (I R A Aggie)
Re: Random numbers (Perl fails this test) <rootbeer@teleport.com>
reading file permissions (David Shirley)
Re: Running a CGISite! <rootbeer@teleport.com>
Re: Script Headers (Abigail)
Re: Script Headers <rootbeer@teleport.com>
Re: Whois help <rootbeer@teleport.com>
Re: Why does $# cause loss of newline? <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 04 Apr 1998 03:15:20 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: bitbucket for (,$b,,,$e,,)=split(/\,/,$string)
Message-Id: <352589a8.524144494f47414741@radiogaga.harz.de>
Robert Lopez (Robert.Lopez@abq.sc.philips.com) wrote:
: Using perl 5.004_04
: Every perl book I have shows some use of split such as
: ($login, $passwd, $uid, $gid, $gcos, $home, $shell)=split /:/;
: but I find none of them address when not all fields are needed.
($passwd, $home, $shell)=(split /:/)[1,5,6];
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Fri, 3 Apr 1998 22:02:44 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ralph Moch <ralphmoch@swol.de>
Subject: Re: CGI-BIN: Link to other directories within a password secured area
Message-Id: <Pine.GSO.3.96.980403220130.1988M-100000@user2.teleport.com>
On Thu, 2 Apr 1998, Ralph Moch wrote:
> if I reach the password protected area by transmitting password and
> username I get a new HTML page. Within this page I want zo place some
> links which only the user, in this case it=B4s me, can connected to. If I
> click on a link, the server sends me the message: You have no permission
> to enter this site. I think I have to create a file which has got the
> user datas, how can I do that?=20
If this is possible, it's done the same way with Perl as it would be done
if written in C++, Logo, or ADA. That's a sign that it's not
Perl-specific. The people in a newsgroup about CGI scripting and
webservers should be able to give you a better and more-complete answer
than we can give here. Good luck!
--=20
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 Apr 1998 05:24:36 -0000
From: spider@Orb.Nashua.NH.US (Spider Boardman)
Subject: Re: contexts: is there such a thing as array?
Message-Id: <199804040518.AAA15496@Orb.Nashua.NH.US>
Randal Schwartz wrote (in part):
>
> >>>>> "Spider" == Spider Boardman <spider@Orb.Nashua.NH.US> writes:
>
> Spider> Maybe. If you can explain away this one:
>
> Spider> $a = @hash{'a','b','c','d'};
>
> A slice in a scalar context, by definition, returns the last element
> of that slice. This falls out directly of the equivalent full-blown
> form:
>
> $a = ($hash{a},$hash{b},$hash{c},$hash{d});
>
> where we see our friend, the comma operator, happily chugging away in
> this scalar context, returning $hash{d} after evaluating each of the
> other three.
Which is merely an equivalent way to get the same value in $a,
and not the mechanim by which that happens. Instead, the right
answer is simply that the hash-slice (and, for that matter,
array-slice) operator behaves that way in scalar context. (Yes,
I was being deliberately disingenuous.)
> Thus, once again, THERE IS NOT A LIST VALUE IN A SCALAR CONTEXT.
> EVER.
Sorry, but that's not quite true. It is true (so far as I can
tell) that you can't really get a true multiple-stack element
list in scalar context without an XSUB(*), but there's a matter
of definitions to be noted here. The problem is with the fact
that Perl has a `list' operator.
With a perl executable built with -DDEBUGGING, try this one:
perl -Dsltx -e 'sub foo {(1,2)} @a=&foo; $a=&foo'
Note the execution of a `list' operator, and the fact that it
searches for its context (thus the "found sub #1"), and in the
second call suddenly decides to return its rightmost element
instead of all of them. The list operator itself is sensitive to
its context, even when the parser didn't convert it to a regular
comma operator(**). This is where the matter of definitions
comes in--the list operator does produce a value in a scalar
context. It's just not the same as the value that it produces in
list context.
(*) The parser (or its peephole optimizer--I didn't check to see
which) leaves a list operator behind even for C<$a=(1,2)>, but it
does drop the 1 out of the picture.
(**) Even when an XSUB does return multiple elements, the
subroutine-exit code in the interpreter massages the stack, so
only the rightmost is still present by the time you get to try to
muck with that return value. Also, if an XSUB returns 0 elements
(a 0-length list, the equivalent of C<return ();>), an C<undef>
is manufactured so that there'll be a value for scalar context.
Either way, by the time you get to use the value in scalar
context, there's exactly one scalar value present. The latter is
the same as the treatment the list operator gives to () in a
scalar context. In fact, it's effectively applying the list
operator to the return from an XSUB, letting the list operator
pay attention to the prevailing context, except that it does it
in-line there rather than actually inserting the operator.
So, why the long explanation to show that there's still only one
value provided to a scalar context? The point is that scalar
context affects the return value of various operators, INCLUDING,
BUT NOT LIMITED TO, the list operator. You can't get a
multi-element list of values in scalar context(***). Each of the
operators which can produce a multi-element list in list context,
including hash slices, array slices, and the list operator itself
will return a single scalar value in scalar context.
(***) If Randal had phrased his statement that way (in terms of
having a list of multiple values), then I wouldn't have taken any
issue with it. Then again, if you don't already know about
Perl's list operator, maybe you need his phrasing instead of
mine. To me, though, "list value" is simply the value of the
list operator. Left at that, thoughe, the first question you
should ask is, "in what context?"
So, if your understanding of "list value" is that it's a list of
scalar values, with the emphasis on the plural, then Randal's
statement above DOES apply to you. If, on the other hand, your
understanding of Perl's operators includes the list operator,
then a "list value" is something which depends on its context,
and in scalar context, it "just happens" to be a scalar, as one
should expect. That understanding, however, means that the
notion of having a list of multiple values outside of list
context is something that no longer makes sense to you, since you
know that Perl's operators pay attention to their context.
--
Spider Boardman (at home) spider@Orb.Nashua.NH.US
The management (my cats) made me say this. http://www.wp.com/spider
PGP PK fingerprint: 96 72 D2 C6 E0 92 32 89 F6 B2 C2 A0 1C AB 1F DC
------------------------------
Date: Sat, 04 Apr 1998 01:49:13 -0500
From: Bob Trieger <sowmaster@juicepigs.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: current week
Message-Id: <3525D7E9.5DAE@juicepigs.com>
Bart Lateur wrote:
>
> Bob Trieger wrote:
>
> >a start would be:
> >
> > @date = localtime();
> > $week = $date[7]/7;
>
> Close. But it really depends on what day of the week the year starts
> with. In other words: the first week is but rarely a complete week.
>
> And shouldn't you apply int() on this result?
Correct on both counts. That is exactly why I said "a start would be".
He was looking for direction and I was just giving him a shove.
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: Sat, 04 Apr 1998 03:25:45 +0200
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Database sorting problem
Message-Id: <35258c19.524144494f47414741@radiogaga.harz.de>
Andy Biegel (chefandy@culinary.com) wrote:
: I'm trying to sort the database by the fourth field in each record
: (364604,364603,364605,...). Any suggestions how to do this? Thanks.
perlfaq4.pod, "How do I sort an array by (anything)?"
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
Ceterum censeo | work: mv@pdv-systeme.de
Redmondem delendam esse. | http://www.pdv-systeme.de/users/martinv/
| home: martin@radiogaga.harz.de
------------------------------
Date: Fri, 3 Apr 1998 22:21:10 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Anthony <anthony@SPAMISBADpce.net>
Subject: Re: Delete file on server!
Message-Id: <Pine.GSO.3.96.980403222043.1988N-100000@user2.teleport.com>
On Fri, 3 Apr 1998, Anthony wrote:
> try system("rm filename");
That's a waste of a call to system. Try unlink next time. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 04 Apr 1998 02:01:38 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Determining variable types
Message-Id: <3525DAD5.210C30C4@coos.dartmouth.edu>
Chris Formulak wrote:
>
> For a given variable, is there a way to tell if it contains a string or
> a number? For example, let's say I had two variables:
>
> $str = "123";
> $num = 123;
1. Ignore the posts directing you to the FAQ. While the responses were
well-intentioned, the answer in the FAQ does not deal with the specific
example you gave. (The FAQ answer tells you how to distinguish between "123"
and "foo", not "123" and 123.)
2. Why do you need to do this? In almost all cases in Perl, whether the
internal representation of a value is primarily a number or primarily a string
does not make a difference.
3. I cannot think of any easy way to do this, but it must be possible, because
the & operator does it.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 3 Apr 1998 22:34:39 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Caffin <UCE-trap_synic@omen.net.au>
Subject: Re: Diddling with search engines via CGI
Message-Id: <Pine.GSO.3.96.980403222654.1988O-100000@user2.teleport.com>
On Thu, 2 Apr 1998, Peter Caffin wrote:
> klassa@aursgh.aur.alcatel.com (John Klassa) did cunningly address to
> comp.lang.perl.misc..
> :So Tom (Phoenix, in this case :-)) should spend extra time answering the
> :same questions over and over again. How many times does somebody have to
> :say "go to comp.infosystems.www.authoring.*", for example?
>
> If you can't answer a question properly, don't bloody do so.
I'm always glad when I can answer a question properly. But it's also
important to know _where_ to answer it. If I'm reading a newsgroup about
CGI scripting, I'll answer CGI questions. If I'm reading a newsgroup about
Perl, I'll direct CGI questions to a place where a better and more
complete answer would be appropriate.
Usenet is organized into categories because that's more efficient: If it's
a CGI question answered in a Perl newsgroup, that answer will help fewer
of the people looking for CGI answers and merely annoy more of the people
looking for Perl answers.
But don't argue this with me! :-) I advise dissenters who disagree with
that policy to replace the charter of this newsgroup with one of their own
design. That's what the charter is there for, of course, to set the
guidelines for what the group is about. If you change the charter, I'll go
along with the new one, no problem.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 04 Apr 1998 01:19:51 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: eval with text files
Message-Id: <3525D108.6BE70CEB@coos.dartmouth.edu>
Craig Berry wrote:
>
> Well, the e's are harmless in this case, so don't feel too bad. For a
> straight variable substitution, one level of e processing acts just like
> zero -- and I'm still not entirely clear on why that is.
Because the rhs of a substitution is normally subjected to double-quotish
processing, but with /e, the double-quotish processing is not done.
So, s/foo/$var/ yields "$var", which evaluates to the value of $var, and
s/foo/$var/e yields eval { $var }, which also evaluates to the value of $var.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 3 Apr 1998 22:56:27 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Daniel Lortie <dlortie@nt.com>
Subject: Re: File Renaming Problem (Please Help...)
Message-Id: <Pine.GSO.3.96.980403224913.1988P-100000@user2.teleport.com>
On Fri, 3 Apr 1998, Daniel Lortie wrote:
> Hi I am having trouble renaming a file and I have absolutely no idea
> why.
>
> Here is my code:
> --- start
> foreach $file (@filestomove)
You haven't initialized @filestomove. Is this really the start of your
code?
> {
> chomp;
What are you chomping? Surely not $file, since chomp's default is $_. But
you haven't initialized $_ either. Hmmm...
> $name = basename($file);
> $destname = "$spooldir/$name";
> $tmpname = $destname;
> $tmpname =~ s/std/incomplete/g; #copy as incomplete before
> renaming as std
> if (rename("$file","$tmpname") == 0) { print "ren1 failed: $!\n";
> }
There's nothing _wrong_ wrong with that, but I'd avoid the excesses:
warn "rename 1 failed: $!" unless rename $file, $tmpname;
> if (rename("$tmpname","$destname") == 0) { print "ren2 failed:
> $!\n"; }
And why do you do this in two steps? Why not rename it directly to
$destname?
> I am trying to move a file from one directory to another (with an
> intermediate step which is necessary because the final directory has a
> daemon which will pick up any files matching *std*)
I don't follow that reason. But okay. :-)
> ren1 failed: No such file or directory
> ren2 failed: No such file or directory
Maybe you didn't have the right filename in your list to start with. Could
the names have newlines on the ends?
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 04 Apr 1998 01:28:02 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: How do I strip newlines from a var
Message-Id: <3525D2F4.ACE574CC@coos.dartmouth.edu>
Lasse Hillerxe Petersen wrote:
>
> In article <6g141i$9cs$1@client3.news.psi.net>, you wrote:
>
> >Bryan Sapot (bsapot@office1.gundaker.com) wrote on MDCLXXV September
> >MCMXCIII in <URL: news:6g11rf$pmf$1@newsin-1.starnet.net>:
> >++ how can i strip new lines out at var.
> >++
> >
> >Removing new lines is very tricky, as the manual tells you so.
> >Ignore the complicated things in the manual, and put in this
> >neat little trick:
> >
> >$var=join+q,,,grep{ord${qq$\137$}<10 or+10<ord}split+q,,,$var;
> >
> >If you're old enough not to read the manual, you won't have a
> >problem understanding the above line.
>
> While I agree that FAQs are a nuisance, I do wonder why you choose to post
> an "answer" like that. What's your point?
>
> [rant rant rant]
Up yours. I found Abigail's suggestion informative, creative, and quite
amusing. Answering blatantly obvious questions with blatantly non-obvious
solutions is a harmless means of defusing frustration at the newbies who post
such questions, and also an entertaining way to demonstrate your skill at
hacking Perl.
Ask a stupid question, get a stupid answer. (Only we go one better; we give
intelligent, if obtuse, answers. ;-)
BTW, your newsreader appears to be attributing quoted text with the pronoun
"you" instead of the sender's name or email address. Odd.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 04 Apr 1998 02:07:00 -0500
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <luwwd6ysiz.fsf@asfast.com>
chip@mail.atlantic.net (Chip Salzenberg) writes:
> According to Lloyd Zusman <ljz@asfast.com>:
> >So perhaps we should rename comp.lang.perl.misc to something like
> >comp.lang.perl.we-are-pretending-to-be-a-university
>
> You miss the point. All newsgroups must be like this, because the
> supply of ignorance (no insult intended here) always exceeds the
> supply of volunteer expertise. Instructional forums are broken if
> they don't optimize for multiplying the force of instruction.
Well, given this way of looking at things, I contend that the Perl
newsgroups could be optimized for learning somewhat better than they
currently are.
First of all, a university has classes geared for various levels of
expertise. There are beginning, intermediate, and advanced classes,
and this is done for a good reason: learning would not be optimized if
all levels of students were taught in one class.
If we were to create some sort of ".novices" newsgroup in addition to
the current comp.lang.perl.misc newsgroup, we could optimize each of
these two newsgroups for the target audience in each one. The people
making use of the more advanced newsgroup could spend less time
explaining introductory topics over and over to new Perl users
(thereby lowering their levels of frustration and thereby also
probably lowering the level of rudeness that some of them display).
By the same token, these topics would be more appropriate to discuss
in the other, ".novices" newsgroup.
Just like there are those (such as elementary school and high school
teachers) who gladly take it upon themselves to explain, semester
after semester, the same introductory topics to their novice students,
I'm confident that there will be a steady supply of people who are
willing to take on this kind of task in a ".novices" newsgroup.
> The only alternative to a university model is a mob with a gradually
> falling collective expertise.
Not true. Most education systems I'm familiar with consist of more
than just universities. There are primary schools, secondary schools,
specialized "trade" schools, etc. There are therefore a number of
other options in addition to "mob rule" and a university model.
And a couple last points: First of all, there is nothing about a
"university model" that requires professors to be rude and
condescending to their students. Some very kind and supportive
professors are also very good at encouraging people to study and learn
on their own instead of waiting to be spoon-fed knowledge.
And finally, one aspect of the "university model" consists of
classroom time where students can actually ask questions of the
professor. If this professor is an experienced teacher, then he or
she will have already answered many of these same questions over and
over and over in other classes. In my opinion, if a teacher cannot
explain the same topics repeatedly to different classes without
becoming consistently frustrated, testy, rude, and condescending, then
that teacher should probably consider a different profession.
I would say something similar to a few of the people in
comp.lang.perl.misc: there's a steady flow of novices coming into this
newsgroup, and if can't discuss the FAQ and other introductory topics
with these novices without becoming frustrated, testy, rude, and
condescending, then you probably should just not post anything at all
and just hit the 'n' key.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Sat, 04 Apr 1998 02:21:34 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <3525DF82.D5BB6DD4@coos.dartmouth.edu>
smitty77@pacbell.net wrote:
>
> For the average novice, who may be asking for the first time or simply might
> need and expect more than "go look it up in the FAQ", I offer this. If someone
> came up to me at work and asked a question which I knew could easily be answered
> in a book that was sitting on a shelf, I wouldn't tell that person "your answer
> is in that book over there" and then go back to what I was doing. I would
> probably go get the book, find the place in the book where the information was
> and point it out to them, perhaps even going so far as to explain the answer
> over and above what the book said. That way, I've not only told them that a
> book existed that might help them, but I showed them where the book was and
> showed them where in the book the answer was. Common courtesy. I don't think
> that's too much to ask. Especially in here, since you can simply not respond at
> all if you don't want to be bothered with these nuisance posts.
On the other hand:
1) At work, you don't get 20 to 30 people coming up to you every single day to
ask the same questions over and over again.
2) You can spend 15-30 minutes looking up the answer for your coworker, then
explaining it to him or her. That doesn't carry over to Usenet.
3) The posts are not bothersome because we respond to them. They're
bothersome because they were posted. Not responding to them does not make
them any less of a nuisance.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 4 Apr 1998 06:44:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Obfusticator
Message-Id: <6g4ksn$t1j$1@client2.news.psi.net>
tory1 (tory1@mail.idt.net) wrote on MDCLXXVII September MCMXCIII in
<URL: news:3525CDB2.B45589D6@mail.idt.net>:
++ Hi All,
++ I have some perl programs I would like to distribute but
++ I would like the perl code to be "hidden". It strikes me
++ that
++ a "random" obfusticator would shroud the code sufficiently.
++
++ Does anyone know of any code I could use to effectively
++ use for this purpose.
Just write bad code, and noone will attempt to "steal" it.
Abigail
--
The Internet Revolution was founded on open systems: an open system is one
whose software you can look at, a box you can unwrap and play with. It's
not about secret binaries or crippleware or brother-can-you-spare-a-dime
shareware. If everyone always had hidden software, you wouldn't have
1/100th the useful software you have right now.
And you wouldn't have Perl.
[Tom Christiansen in `The new Camel and compiling perl'
<news:53mal3$4b5$1@csnews.cs.colorado.edu>]
------------------------------
Date: Sat, 04 Apr 1998 02:11:05 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Obfusticator
Message-Id: <3525DD0D.BF72BA5F@coos.dartmouth.edu>
tory1 wrote:
>
> I have some perl programs I would like to distribute but
> I would like the perl code to be "hidden". It strikes me
> that a "random" obfusticator would shroud the code sufficiently.
A random obfusticator:
#/usr/local/bin/perl -pi.bak
s/./chr 0x20 + rand 0x5F/ge;
That should result in more than sufficient shrouding.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sat, 04 Apr 1998 01:02:35 -0500
From: Ronald J Kimball <rjk@coos.dartmouth.edu>
Subject: Re: Perl Databases...
Message-Id: <3525CCFB.92760470@coos.dartmouth.edu>
Sandy Cash wrote:
>
> John Porter wrote:
> >
> > Andrew F. Lee wrote:
> > >
> > > > Bill Lewis <Bill.Lewis@mci.com> wrote:
> > > >
> > > > > Then in the script I assign keys and values like such:
> > > > >
> > > > > %info = $key => $value;
> > > >
> > > > $info{$key} = $value;
> > > >
> > >
> > > %info = ($key => $value);
> > >
> > > maybe it was a typo ....
> >
> > Maybe, but it's still wrong. With that assignment,
> > %info will never have more than one key.
>
> Uhh...how do you mean? If you mean that, if one initializes a hash with
> the syntax above, %hash = ($key => $value); , the hash can never be
> grown/changed to include additional key/value pairs, then you're quite
> incorrect:
> [...]
> Or did I misunderstand your assertion?
You misunderstood the assertion. If you reread the text above, you will see
that the original poster was *assigning* keys and values like this:
%hash = (key => 'value');
He was not initializing the hash with that code; he was assigning to it (over
and over again within a loop). Thus, as John said, the hash will never have
more than one key.
You should probably read the entire thread if you're not clear about what a
specific message is saying.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J. Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 4 Apr 1998 00:00:23 -0600
From: peisch@news.etude.com (Peter Eisch)
Subject: Re: Ping
Message-Id: <6g4i9n$he4$1@kelly.etude.com>
I don't think the latest rollup includes the spiffy Ping, check out
CPAN for the multi protocol version...
peter
Steven L Reid (slreid@micron.net) wrote:
: Humm, seems my version of Net::Ping negleted that feature? My latest build
: (which isn't more than a couple months old) still says TCP? I'd still like
: to hear an answer though. The I hate having to use the system command (and
: it's inherit slowness) to ping hosts!
:
------------------------------
Date: Sat, 04 Apr 1998 02:09:27 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Ping
Message-Id: <fl_aggie-0404980209280001@aggie.coaps.fsu.edu>
In article <6g4fh7$b5i$1@news01.micron.net>, "Steven L Reid"
<slreid@micron.net> wrote:
+ Humm, seems my version of Net::Ping negleted that feature? My latest build
+ (which isn't more than a couple months old) still says TCP? I'd still like
+ to hear an answer though. The I hate having to use the system command (and
+ it's inherit slowness) to ping hosts!
[hacked & sliced out of perldoc Net::Ping]
use Net::Ping;
$p = Net::Ping->new("icmp");
foreach $host (@host_array)
{
print "$host is ";
print "NOT " unless $p->ping($host, 2);
print "reachable.\n";
sleep(1);
}
$p->close();
>From my installation - lib/perl5/Net/Ping.pm:
$VERSION = 2.02;
$def_proto = "udp"; # Default protocol to use for pinging
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>
------------------------------
Date: Fri, 3 Apr 1998 23:12:06 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom Rokicki <rokicki@cello.hpl.hp.com>
Subject: Re: Random numbers (Perl fails this test)
Message-Id: <Pine.GSO.3.96.980403231017.1988S-100000@user2.teleport.com>
On 3 Apr 1998, Tom Rokicki wrote:
> Perl's random numbers (from rand()) are atrocious---almost useless.
> They just aren't very random.
Well, Perl doesn't make them up all by itself. When you compile Perl, you
can choose what function to use. If you don't like the default, you can
choose another.
> I believe that Perl should provide an interface to drand48() and
> friends (erand48(), lrand48(), nrand48(), mrand48(), jrand48(),
> srand48(), seed48(), lcong48()) and use a different function (perhaps
> random() derived from drand48()) as its default random number
> generator.
You may compile it that way, if you wish. Or, if you think that one of the
others should be the default, feel free to submit a patch. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 03 Apr 1998 23:02:04 -0800
From: david@dpeinc.com (David Shirley)
Subject: reading file permissions
Message-Id: <david-ya02408000R0304982302040001@enews.newsguy.com>
Newbie question here:
How does one go about reading the existing permissions on a file? I can
figure out how to change them but I'm looking for a simple way to determine
what they currently are for owner, group and world.
Thanks in advance!
David
------------------------------
Date: Fri, 3 Apr 1998 23:26:19 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: TheTool <hobbezz@hotmail.com>
Subject: Re: Running a CGISite!
Message-Id: <Pine.GSO.3.96.980403232427.1988V-100000@user2.teleport.com>
On Sat, 4 Apr 1998, TheTool wrote:
> How difficult is it to retrieve information from a
> FORM in an HTML file without Using CGI.PM?
This is like asking, "How difficult is it to build a house without using
tools?" But, more importantly, why would you want to avoid using CGI.pm?
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 4 Apr 1998 06:46:48 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Script Headers
Message-Id: <6g4l0o$t1j$2@client2.news.psi.net>
Thumperz (-nospam-thumperz@deltanet.com) wrote on MDCLXXVII September
MCMXCIII in <URL: news:3525B3C2.76F7@deltanet.com>:
++ I was using a perl program in my cgi-bin for a wwwboard. I ran the
++ program for awhile with no problems, then started getting an error.
++ The error I get is a "Premature end of script headers".
That means you have a bug in your program.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle 'print +(HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET", "http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content)) =~ /(.*\))[-\s]+Additional/s) [0]'
------------------------------
Date: Fri, 3 Apr 1998 23:15:29 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Thumperz <-nospam-thumperz@deltanet.com>
Subject: Re: Script Headers
Message-Id: <Pine.GSO.3.96.980403231516.1988T-100000@user2.teleport.com>
On Fri, 3 Apr 1998, Thumperz wrote:
> I was using a perl program in my cgi-bin for a wwwboard. I ran the
> program for awhile with no problems, then started getting an error.
> The error I get is a "Premature end of script headers". Any help would
> be appreciated. Thanks in adavance,
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
http://www.perl.com/CPAN/
http://www.perl.org/CPAN/
http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.org/CPAN/doc/manual/html/pod/
Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 3 Apr 1998 23:09:39 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Chad Casselman <c2@3-g.com>
Subject: Re: Whois help
Message-Id: <Pine.GSO.3.96.980403230846.1988Q-100000@user2.teleport.com>
On Thu, 2 Apr 1998, Chad Casselman wrote:
> I need to know how to do a whois in perl. Say that I have bsc.net I
> want to know what company and state they are from. How can you do this
> in perl?
You could either implement the whois protocol in Perl, or call an external
program which already does so. The latter is probably fine unless you're
going to do this thousands of times, give or take. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 3 Apr 1998 21:58:10 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: John Lukas <jalukas@lucent.com>
Subject: Re: Why does $# cause loss of newline?
Message-Id: <Pine.GSO.3.96.980403215652.1988L-100000@user2.teleport.com>
On Thu, 2 Apr 1998, John Lukas wrote:
> Subject: Why does $# cause loss of newline?
It's a bug, no doubt about it. But since $# is deprecated, there's not
much reason to fix it - and good reason not to, since if an old program
"works" as is, it would be bad to break that! But, as I always tell my
students, if you want a particular number format, use sprintf. Hope this
helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2247
**************************************