[18194] in Perl-Users-Digest
Perl-Users Digest, Issue: 362 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 27 00:05:38 2001
Date: Mon, 26 Feb 2001 21:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983250307-v10-i362@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Feb 2001 Volume: 10 Number: 362
Today's topics:
Re: Array length <uri@sysarch.com>
Re: Check Out a web based forum of this group at : <callgirl@la.znet.com>
Re: FAQ 4.73: How do I verify a credit card checksum? <callgirl@la.znet.com>
Re: Help deciphering Perl code ianb@ot.com.au
Re: Help deciphering Perl code (Craig Berry)
Re: HELP needed on a simple Parse::RecDescent program ( (Gwyn Judd)
Looking for advice from seasoned Perl experts <parrot0123@yahoo.ca>
Re: LWP Module????? <bwalton@rochester.rr.com>
Re: LWP Module????? blah@blah.blah.invalid
Re: perl newbie questions: database of complex configur <bwalton@rochester.rr.com>
Perl/HP-UX - Odd $ENV Behavior <bb22@uswest.net>
Re: Please Help with 10 line programm -- beginner quest <callgirl@la.znet.com>
Re: Please Help with 10 line programm -- beginner quest (Gwyn Judd)
Re: print "problem" (Was: Re: local vs. global context) (Damian James)
Re: print "problem" (Was: Re: local vs. global context) <um@no.com>
Re: print "problem" (Was: Re: local vs. global context) (Tad McClellan)
Re: print "problem" (Tony L. Svanstrom)
Re: print "problem" (Tony L. Svanstrom)
Re: question on how to code a program <uri@sysarch.com>
Re: Script Problems - Please Help <bwalton@rochester.rr.com>
Re: Somewhat complicated hash from DB question <um@no.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Feb 2001 04:13:27 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Array length
Message-Id: <x766hwhift.fsf@home.sysarch.com>
>>>>> "VE" == Victor Eijkhout <victor@eijkhout.net> writes:
VE> Uri Guttman <uri@sysarch.com> wrote:
>> if $a{b} is an array REF (it can't be an array),
VE> Apperently. I don't notice that much: Perl makes it too easy to just
VE> write $a{b}[2] and I can just pretend it's a multi-dimensional array and
VE> don't have to think about how that is implemented.
implementation has nothing to do with it. you are stuck in the syntax of
perl's ref and data structures.
>> then you should read perlref for how to handle refs.
VE> From the state of the perl docs you'd think that it *hurts* to put
VE> all information conveniently together.
well, you can just do that by catting all the file together if that
makes it easier to read. the rest of us like the convenient smaller
packages that focus on on topic. cross referencing to other documents is
normal for us. another alternative is for you to load perl 4 and it
single 40 page man file.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 26 Feb 2001 18:15:08 -0800
From: Kiralynne Schilitubi <callgirl@la.znet.com>
Subject: Re: Check Out a web based forum of this group at :
Message-Id: <3A9B0DAC.91233B5C@la.znet.com>
TeKno wrote:
> http://www.supportinfo.com
look in the forums, enjoy the rest of the pages too!
Received from "nt4_pro@supportinfo.com" registered
administrative contact at supportinfo.com,
"I have received your complaint, and I must say that after looking at the
pages here and the message sent, it looks to me like this is a free service
that has been mentioned. I do not understand how you get "commercial" out of
a free service. Since the notices posted were in reference to another "free"
method of reaching the information contained in the specific groups
mentioned they were on the topic of the groups where posted. This therefore,
in my opinion was not spam, unless of course there were numerous repeats of
the same information.
Please feel free to reply with further concerns or rebutal if you wish,
nt4_pro@supportinfo.com"
This is hilarious. You cross-post your spam via Prodigy,
provide a fraudulent return address, try this mule manure
response on me and, you are not responsible enough nor
brave enough to provide your name to me as I provided
mine to you.
As I said from the git go, you people are total bozos.
Godzilla!
------------------------------
Date: Mon, 26 Feb 2001 20:45:36 -0800
From: Kiralynne Schilitubi <callgirl@la.znet.com>
Subject: Re: FAQ 4.73: How do I verify a credit card checksum?
Message-Id: <3A9B30F0.9B29FD42@la.znet.com>
PerlFAQ Server wrote:
> How do I verify a credit card checksum?
> Get the Business::CreditCard module from CPAN.
Coding for this can be accomplished in just under
fifty lines of code, even less if obfuscated, and
it is very simple code.
A more accurate FAQ, a more realistic FAQ would
include a suggestion similar to,
"You may also research and learn from this module
then write your own code. This is not difficult
and could be customized to suit your needs,
more specifically and more efficiently."
Godzilla!
------------------------------
Date: 27 Feb 2001 02:30:10 GMT
From: ianb@ot.com.au
Subject: Re: Help deciphering Perl code
Message-Id: <97f3fi$p7d$1@news.netmar.com>
In article <20010226200158.02634.00000064@ng-ct1.aol.com>, Falc2199
<falc2199@aol.comNOJUNK> writes:
>
>The following code selects a line randomly from a file....
>
>while (<FILE>)
>{
> if (rand($.) < 1)
>{
> $line = $_;
>}
>
>}
>
>Can someone please explain to me how this code is working?
>
>If you can not decipher the entire thing, can you tell me what '$.' is?
>How would rand react to it?
$. is "The current input line number of the last filehandle that was
read", in this case FILE.
rand(n) generates a pseudo-random number in the range 0..(just under n).
The chances of this being under 1 are effectively 1/n. So there is a 1/n
chance that the last line will be chosen, a (n-1)/n * 1/(n-1) = 1/n
chance that the (n-1)th line will be chosen, etc.
The nice thing about this algorithm is that it only has to read and
store a line at a time, without knowing in advance how many lines there
are. I'm fairly sure I've seen this in the Cookbook or the FAQ (just
checked...there's a more succinct version of it in the Cookbook sect 8.6).
Regards,
Ian
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Tue, 27 Feb 2001 03:17:40 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help deciphering Perl code
Message-Id: <t9m72kl7vs2u65@corp.supernews.com>
Falc2199 (falc2199@aol.comNOJUNK) wrote:
: The following code selects a line randomly from a file....
[reformatted for compactness and indentation]
:
: while (<FILE>) {
: if (rand($.) < 1) {
: $line = $_;
: }
: }
:
: Can someone please explain to me how this code is working?
This is one of my all-time favorite nonintuitive (for me) algorithms.
First, $. is the current line number, starting at 1, and rand returns a
floating-point number in the range [0..n), where n is its argument.
[0..n) means "from 0 up to but not including n"
So, the first line gets read. $. is 1, so rand will return a number
between 0 and 0.999999999. Thus the test for <1 is guaranteed to succeed,
and $line is set to be the first line.
Now, the second line gets read. The rand range is now 0-2, so there is a
1/2 chance that $line becomes the second line instead. Then a 1/3 chance
that it's the third line, and so on and on. If you do the math, it ends
up being the (utterly surprising to me) case that the odds of picking any
one line out of the file are equal! You can do the math to show that it's
true -- it's not complicated, and makes an interesting exercise.
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "When the going gets weird, the weird turn pro."
| - Hunter S. Thompson
------------------------------
Date: Tue, 27 Feb 2001 03:42:58 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: HELP needed on a simple Parse::RecDescent program (problem: some rules are matched twice)
Message-Id: <slrn99m8i0.gdp.tjla@thislove.dyndns.org>
I was shocked! How could Randal L. Schwartz <merlyn@stonehenge.com>
say such a terrible thing:
>>>>>> "Eric" == Eric Liao <ekliao@hotmail.com> writes:
>
>Eric> I am a new user of Parse::RecDescent. I tried to use v1.80 to
>Eric> implement a simple parser with a simple grammar for parsing c/c++/java
>Eric> code. The result looks good except that 5 rules seem to be matched
>Eric> twice (see output and expected output below). I could not figure out
>Eric> why. Any help would be greatly appreciated. Please e-mail
>Eric> ekliao@hotmail.com or post to the groups. Thank you.
>
>You can't print out your result while you are parsing it, because you
>can't "unprint" a backtrack. You backtracked in "expression" from the
>first subrule to the second subrule, but you'd already printed out the
>result of a successful first step of that first subrule.
>
>Don't do that. Pass the data upstairs, and have the final top-level
>rule do all the work.
Alternatively, you could make the grammar LL(1) so there is no need for
backtracking. There is only the one problematic non-terminal so it
shouldn't be too hard. Simply replace this:
expression : unary_expr PLUS_OP expression
| unary_expr
with this:
expression : unary_expr plus_expression
plus_expression : PLUS_OP expression
| # nothing
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Fortune's real live weird band names #13:
Alien Sex Fiend
------------------------------
Date: Tue, 27 Feb 2001 04:59:29 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Looking for advice from seasoned Perl experts
Message-Id: <RuGm6.308604$f36.11218381@news20.bellglobal.com>
Hi,
I'm a computer programmer who'se recently gotten into Perl. I've fiddled
around with it a little before, but only basically. Now I'm doing some
really nice work using the language and am generally really pleased with the
results I'm getting.
To avoid any confusion, I'm not looking for help figuring out what's wrong
with some snippet of code. I was tempted a few times but I managed after a
lot of hair pulling to figure the problem out for myself, which makes the
solution that much sweeter. I'm sure, however, that if I was looking for
that kind of help you people would be right there with the answer for me.
I'm designing a website to handle auctions/messages/e-commerce and stuff
like that. My employer is anticipating a good amount of traffic to the
site. I'm generally doing pretty good in making these applications do what
I want them to do, but I understand there's some things to keep in mind when
designing internet programs that will be getting a lot of traffic. I'm used
to designing single-user applications, and was hoping for some advice on how
to make my Perl code bulletproof, so that it doesn't crash if too many
people start accessing the website.
I'm inexperienced at handling things like web servers and how much load they
can take and stuff like that - any advice that you guys can give me would be
great.
Thanks
------------------------------
Date: Tue, 27 Feb 2001 02:20:24 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: LWP Module?????
Message-Id: <3A9B0F4C.D46A4B19@rochester.rr.com>
lefkogt@codenet.net wrote:
>
> Is there GOOD documentation (with examples) for the Perl LWP module? There is a
> book which is no longer in print -- there must be something online for LWP???
> If not, what else can be used in similar fashion, for example, get a webpage and
> store it in a Perl variable so you can use REGEX to find information within that
> webpage?
> Gary
Have you looked at:
perldoc LWP
perldoc LWP::Simple
perldoc LWP::UserAgent
etc on your hard drive? IMO, it's pretty good.
--
Bob Walton
------------------------------
Date: 27 Feb 2001 02:34:25 GMT
From: blah@blah.blah.invalid
Subject: Re: LWP Module?????
Message-Id: <97f3nh$5gue$1@newssvr05-en0.news.prodigy.com>
Bob Walton <bwalton@rochester.rr.com> wrote:
> lefkogt@codenet.net wrote:
>>
>> Is there GOOD documentation (with examples) for the Perl LWP module? There is a
>> book which is no longer in print -- there must be something online for LWP???
>> If not, what else can be used in similar fashion, for example, get a webpage and
>> store it in a Perl variable so you can use REGEX to find information within that
>> webpage?
>> Gary
>
> Have you looked at:
>
> perldoc LWP
> perldoc LWP::Simple
> perldoc LWP::UserAgent
and
perldoc lwpcook
Eric
------------------------------
Date: Tue, 27 Feb 2001 02:44:00 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: perl newbie questions: database of complex configuration files
Message-Id: <3A9B14D6.6F264830@rochester.rr.com>
Lloyd Goodman wrote:
>
> I'm currently writing a script to download a copy of both the running and
> saved configuration on foundry networks switches and then compare the two to
> see if they are the same and then compare them with a central database of
> what these configurations should be. I then want to record this info back
> to the database - it's essenttially going to be used as a tool to backup the
> configurations and to prevent situations where two administartors are
> unwittingly working on the same switch over a period of time and altering
> each others changes.
>
> Can any one suggest an approach to storing all this info in such a way that
> it can be easily compared? I have a reasonable understanding of the unix
> diff command and RCS and so on but can't help feeling there's probably an
> easy (-ish) way to do this with perl that I have no experience of (for
> instance could perl/XML be used, would it make any sense?). Below is a
> simple example of a foundry configuration file. Unfortunately I don't know
> whether the order of the entries in the file will always be the same which
> is alsoone of my main concerns.
...
> Lloyd Goodman
...
I think that Perl hashes tied to DBM-style files would make short work
of your problem. For the most part, you can just treat the tied hashes
as ordinary Perl hashes that just happen to stick around between program
invocations. While it is stated as being deprecated, the easiest way to
use such tied hashes with with the dbmopen (and dbmclose) functions:
perldoc -f dbmopen
The chances are good that dbmopen will default to the best DBM-style
file to use on your system.
You will, of course, need to develop code to parse your data and keep
whatever relevent info you want in your hash.
Note that if you put references to other data structures in a tied hash,
you should use the MLDBM module or equivalent to serialize the data in
the hash, as references don't keep well on disk between program
invocations. Then you have to remember to access and store the
referenced data into individual variables, as doing things like
%mldbmtiedhash{one}{two}[3]=4 won't make it with MLDBM. See:
perldoc -q hash compare
for some ideas on comparing hashes.
--
Bob Walton
------------------------------
Date: Mon, 26 Feb 2001 19:33:38 -0700
From: "Bill Border" <bb22@uswest.net>
Subject: Perl/HP-UX - Odd $ENV Behavior
Message-Id: <pfEm6.7188$Jb2.620164@news.uswest.net>
This is a multi-part message in MIME format.
------=_NextPart_000_0012_01C0A02B.04792520
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi All,
There is a server where I have seen some STRANGE behavior
with what I would consider pretty basic environment setting logic.
To set OS environment variables, I have always used code=20
like:
$ENV{'ORACLE_SID'} =3D "SID1";
and then when I invoke a "lower layer" program with, say,
a system() call. Example:=20
system("my_lower_level_pgm.pl");
then, in the lower level program, I would read the ORACLE_SID
env var by:
$os =3D $ENV{"ORACLE_SID"};
On most servers, this works OK. However, I
have found a server where apparently the env
does not get set by the $ENV{'ORACLE_SID'} =3D "SID1";
and when I try the $os =3D $ENV{"ORACLE_SID"}; I get=20
the error message:
Can't locate object method "ENV" via package "ORACLE_SID" at =
/opt/dbamon/bin/dbamon_ora_sumupdate.pl line 18.
Huh??? What is happening. Could this be that the Perl on this server
where it does not work does not recognize the $ENV associate array
name for the ENV? I'm corn-fused.
TIA,
Bill
--=20
Bill Border
Agilent Technologies
bb22@uswest.net
Low-Cost, UX-Based Oracle/Informix Monitor: http://dbamon.com
------=_NextPart_000_0012_01C0A02B.04792520
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>
<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.3616.1301"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>Hi All,</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2> There is a server where I have =
seen some=20
STRANGE behavior</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>with what I would consider pretty basic =
environment=20
setting logic.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>To set OS environment =
variables, I=20
have always used code </FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT><FONT =
face=3DArial=20
size=3D2>like:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>$ENV{'ORACLE_SID'} =3D =
"SID1";</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>and then when I invoke a "lower =
layer"=20
program with, say,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>a system() call. Example: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial=20
size=3D2>system("my_lower_level_pgm.pl");</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2>then, in the lower level program, I =
would read the=20
ORACLE_SID<BR>env var by:</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT face=3D"QuickType =
Mono">$os =3D=20
$ENV{"ORACLE_SID"};</FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT=20
face=3D"QuickType Mono"></FONT></FONT> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT face=3D"QuickType =
Mono">On most=20
servers, this works OK. However, I</FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT=20
face=3D"QuickType Mono"></FONT></FONT><FONT color=3D#000000 face=3DArial =
size=3D2><FONT=20
face=3D"QuickType Mono">have found a server where apparently the=20
env</FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT=20
face=3D"QuickType Mono"></FONT><FONT face=3D"QuickType Mono">does not =
get set by the=20
<FONT face=3DArial size=3D2>$ENV{'ORACLE_SID'} =3D=20
"SID1";</FONT></FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT face=3D"QuickType =
Mono"><FONT=20
face=3DArial size=3D2></FONT></FONT><FONT color=3D#000000>and when I try =
the <FONT=20
color=3D#000000 face=3DArial size=3D2><FONT face=3D"QuickType Mono">$os =
=3D=20
$ENV{"ORACLE_SID"}; I get </FONT></FONT></FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT =
color=3D#000000><FONT=20
color=3D#000000 face=3DArial size=3D2><FONT=20
face=3D"QuickType Mono"></FONT></FONT></FONT><FONT face=3D"QuickType =
Mono">the error=20
message:</FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT=20
face=3D"QuickType Mono"></FONT></FONT> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><FONT face=3D"QuickType =
Mono">Can't=20
locate object method "ENV" via package "ORACLE_SID" =
at=20
/opt/dbamon/bin/dbamon_ora_sumupdate.pl line 18.<BR></FONT></FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>Huh??? What is =
happening. Could this=20
be that the Perl on this server</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>where it does not work =
does not=20
recognize the $ENV associate array</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>name for the ENV? I'm=20
corn-fused.</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>TIA,</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2>Bill</FONT></DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT color=3D#000000 face=3DArial size=3D2><BR>-- <BR>Bill =
Border<BR>Agilent=20
Technologies<BR><A=20
href=3D"mailto:bb22@uswest.net">bb22@uswest.net</A><BR>Low-Cost, =
UX-Based=20
Oracle/Informix Monitor: <A=20
href=3D"http://dbamon.com">http://dbamon.com</A></FONT></DIV></BODY></HTM=
L>
------=_NextPart_000_0012_01C0A02B.04792520--
------------------------------
Date: Mon, 26 Feb 2001 20:06:48 -0800
From: Kiralynne Schilitubi <callgirl@la.znet.com>
Subject: Re: Please Help with 10 line programm -- beginner questions Thanks Guys
Message-Id: <3A9B27D8.5DFDB086@la.znet.com>
Kiralynne Schilitubi wrote:
> Bart Lateur wrote:
> > Kiralynne Schilitubi wrote:
> > >> What do you mean "using strict"?
(see thread for debate on use strict vs. not using strict)
> You should know by now, I * always * do my homework before
> making any statement which is to be taken as factual.
(snipped timings)
Yes, I do my homework. However this does not make me
a Techno-Geekster. I am just curious scientifically
as opposed to being Curious Yellow although my
lifestyle better reflects this camp film.
After going over my methodology and results, I decided
there is a possibility Benchmark does not truly run
separate processes for comparison timing. My snippet
uses srand. I have considered a possibility calling
srand twice within Benchmark, might be skewing results;
this might affect the second comparison.
I ran new tests, timing each snippet independently and
noting results for several runs as before. Additionally,
I added better controls. For my testing this time, a
snippet was timed using strict and a my (). A second
script did not use strict but did use my (). My third
and final script did not use strict nor my ().
Fastest snippet does not use strict nor my ().
Second fastest does not use strict but uses my ().
Slowest uses both strict and my ().
I found the fastest to still be an average 1.5 percent
faster than the slowest, but only .5 percent faster
than use of my () only in the second fastest script.
My results indicate a standard global variable runs
faster than my () alone and significantly faster than
strict and my ().
However, this is not to suggest extensive testing would
not show my declarations to be faster and more efficient
than global declarations. A .5 percent speed difference
is not enough to be reliable nor to reflect overall
speed differences with larger memory usage.
A 1.5 percent speed difference, though, is enough
to make a safe presumption, not using strict lends
to a more efficient script.
Godzilla! * doing her Techno-Geekster homework *
------------------------------
Date: Tue, 27 Feb 2001 03:49:03 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Please Help with 10 line programm -- beginner questions
Message-Id: <slrn99m8td.gdp.tjla@thislove.dyndns.org>
I was shocked! How could Thoren Johne <thoren@southern-division.com>
say such a terrible thing:
>In article <3A9ACCD1.C1DEA364@ll.mit.edu>, Shane McDaniel aka
>shanem@ll.mit.edu says...
>
>> Cool. It's points like these that I like to tell people that "Every
>> programming language will let you shoot yourself in the foot, however
>> with perl you're using an automatic."
>
>yeah - and logo is no shooting, but bondage ;)
While Java is like having someone nail a loaded gun to your foot.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Start off every day with a smile and get it over with.
------------------------------
Date: 27 Feb 2001 02:22:55 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: print "problem" (Was: Re: local vs. global context)
Message-Id: <slrn99m3qg.92m.damian@puma.qimr.edu.au>
Thus spake Tony L. Svanstrom on Tue, 27 Feb 2001 02:01:20 GMT:
>...
>I have to ask about this, because at 3 AM I just don't get it:
>
>## start
>$t = 2;
> {
> my $t = 1;
> print $main::t . "\n" . print $t;
> }
>## end
>...
>Feel free to call me stupid, as long as you at the same time explain why
>it seems to be printed like "$t$::t$t"?
>
Aptly chosen rename for the thread -- this is a 'print' problem. You
probably want to say:
print "$main::t\n$t\n";
What you have above evaluates the 'print $t' on the right first, printning
the value for $t and returning true (ie, '1'). The other print statement
then faithfully prints $::t, then the return code from the right hand
'print', which happens to be '1'. You can test this by trying other values
for $::t and $t.
Cheers,
Damian
--
@;=0..23;@;{@;}=split//,<DATA>;while(1){for($;=@;;--$;;){next if($:=rand($;+
1))==0+$;;@;[$;,$:]=@;[$:,$;];print "\x"for 0..2*($|+23)}print map{$;{$_}}(@|
,@;);push@|,shift@;if$;[0]==@|;last if!@;;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker
------------------------------
Date: Mon, 26 Feb 2001 21:16:20 -0800
From: "Ben L." <um@no.com>
Subject: Re: print "problem" (Was: Re: local vs. global context)
Message-Id: <3a9b103d$1_2@news2.one.net>
> ## start
> $t = 2;
> {
> my $t = 1;
> print $main::t . "\n" . print $t;
^^^^
> }
> ## end
You must be tired ... you have too many print statements :)
------------------------------
Date: Mon, 26 Feb 2001 21:24:28 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: print "problem" (Was: Re: local vs. global context)
Message-Id: <slrn99m3us.85e.tadmc@tadmc26.august.net>
Tony L. Svanstrom <tony@svanstrom.com> wrote:
><egwong@netcom.com> wrote:
>
>> John Hall <jhall@ifxonline.com> wrote:
>> > If I declare a local variable in a subroutine via "my $variable" but then in
>> > the same subroutine I want to access another variable, from the meat of the
>> > program also named $variable, how do I do that?
>>
>> It's not a Silly Newbie Question, but it is a faq:
>>
>> How can I access a dynamic variable while a similarly named lexical is
>> in scope?
>
>I have to ask about this, because at 3 AM I just don't get it:
>
>## start
>$t = 2;
> {
> my $t = 1;
> print $main::t . "\n" . print $t;
^^^^^
^^^^^ this executes before the "other" print() does
> }
>## end
>
>and the output is:
>
>## start
>12
>1
>## end
>
>Feel free to call me stupid,
<this space intentionally left blank>
>as long as you at the same time explain why
>it seems to be printed like "$t$::t$t"?
Naw, it seems to be printed like: "$t$::t<return value from print()>"
heh.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 27 Feb 2001 03:18:01 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: print "problem"
Message-Id: <1epgzou.175vyop1jjjkqnN%tony@svanstrom.com>
Damian James <damian@qimr.edu.au> wrote:
> Thus spake Tony L. Svanstrom on Tue, 27 Feb 2001 02:01:20 GMT:
> >...
> >I have to ask about this, because at 3 AM I just don't get it:
> >
> >## start
> >$t = 2;
> > {
> > my $t = 1;
> > print $main::t . "\n" . print $t;
> > }
> >## end
> >...
> >Feel free to call me stupid, as long as you at the same time explain why
> >it seems to be printed like "$t$::t$t"?
> >
>
> Aptly chosen rename for the thread -- this is a 'print' problem. You
> probably want to say:
>
> print "$main::t\n$t\n";
Well, yes and no... first it was a mistake, easily spotted, but then I
tried to figure out why it happened the way it did...
> What you have above evaluates the 'print $t' on the right first, printning
> the value for $t and returning true (ie, '1'). The other print statement
> then faithfully prints $::t, then the return code from the right hand
> 'print', which happens to be '1'. You can test this by trying other values
> for $::t and $t.
Now that you mention it... Why do I always insist on figuring things out
in the middle of the night, when I should wait and have a look at 'em in
the morning instead?! =)
/Tony
------------------------------
Date: Tue, 27 Feb 2001 03:18:03 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: print "problem"
Message-Id: <1epgzxd.1nue37j1kz1hgvN%tony@svanstrom.com>
Ben L. <um@no.com> wrote:
> > ## start
> > $t = 2;
> > {
> > my $t = 1;
> > print $main::t . "\n" . print $t;
> ^^^^
> > }
> > ## end
>
>
> You must be tired ... you have too many print statements :)
hehe... not THAT tired. =)
/Tony
------------------------------
Date: Tue, 27 Feb 2001 04:15:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: question on how to code a program
Message-Id: <x71yskhibv.fsf@home.sysarch.com>
>>>>> "SS" == Steven Smolinski <sjs@linux.ca> writes:
SS> Abigail <abigail@foad.org> wrote:
>> The best way to deal with Matt's programs is to invent a time machine,
>> go back into history and kill Matts parents before he was conceived.
>> That would solve the Perl community from a big problem, in both the
>> past, present and future.
SS> I was in my local bookstore, and saw a Perl/CGI book by Matt Wright.
SS> The few pages I skimmed had a few errors, as suspected, and I was
SS> putting it back with a snort when I saw a quote on the back.
i once started a contract and onthe first day found that book on a table
that was in a shared room. i stated i would pick a page at random and
find a mistake. i did that 3 times in a row. i think the odds are longer
to find a page without one. maybe the title page?
SS> The quote was from Randal! It said that the book ought to be on
SS> every programmer's bookshelf or some such glowing comment.
SS> Randal! What's happened? Did they threaten to kill your family?
SS> If you can't speak freely, rot13 your reply and we'll figure out a
SS> way to get you and your loved ones to safe Switzerland!
SS> At least, that's the only explanation for the quote I could come
SS> up with. I mean, they wouldn't take him out of context, would
SS> they?
it was taken out of context. but that is what publishers do with back
cover quotes.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Tue, 27 Feb 2001 02:12:52 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Script Problems - Please Help
Message-Id: <3A9B0D88.4395A945@rochester.rr.com>
Mick Beeby wrote:
>
> I have a Perl script which does whois lookup on multiple TLD's. The problem
> I have is two fold:-
>
> 1) If I name the script with a .pl extension it returns correct information
> regarding whether particular domains are available or not but I sometimes
> get error messages such as 'Use of uninitialized value in transliteration
> (tr///) at f:\mjb-is\mjb-is\cgi-bin\whois.pl line 109. ' and 'Use of
> uninitialized value in pattern match (m//) at
> f:\mjb-is\mjb-is\cgi-bin\whois.pl line 278.' etc. I get several of the
> latter ones. I also get this 'The name specified is not recognized as an
> internal or external command, operable program or batch file.' The results
> do get printed to the screen and are coreect though.
>
> 2) If I name the script with a .cgi extension it works fine without any
> errors but returns false information. i.e. all domain are listed as
> available even when I know which ones are not.
>
> What are the consequences of using a differnet extension? The scripts are in
> the cgi-bin directory. This is getting really annoying as sometimes the .pl
> one works fine without generating the error messages. If you submit a second
> time it usually is OK.
>
> I would appreciate any tips on this. I am not really a Perl programmer at
> heart or though I canpick my way round thigs and work stuff out. I have more
> experience with Javascript, VBScript, ASP etc.
>
> If possible, could you cross post any replies to my email address too at
> mick.beeby@mjb-is.co.uk
...
> Mick
Mick, I don't think folks can give you much help with the info provided
above. The script you mention is too long to post and expect folks to
wade through. Thus, you will need to boil your script down to a small
stand-alone piece hopefully no more than 20 lines long that still
manifests the problems you have, and post the exact piece by cutting and
pasting (don't type it in, as that is sure to result in typos).
The bit about changing the filename extensions and getting different
results is probably a matter of web server and/or operating system
configuration, which is not a suitable topic for this newsgroup. Try a
web server newsgroup (hopefully one for the web server you are using)
for help with that.
--
Bob Walton
------------------------------
Date: Mon, 26 Feb 2001 21:10:36 -0800
From: "Ben L." <um@no.com>
Subject: Re: Somewhat complicated hash from DB question
Message-Id: <3a9b0ee5$1_1@news2.one.net>
> foreach $org (keys %blds) {
> foreach $rel (keys $blds{$org}) {
> foreach $this (keys $blds{$org}{$rel}) {
> $x = $blds{$org}{$rel}{$this}{A_COLUMN}
> }
> }
> }
The only problem I see is the dereferrencing of your nested hashes in the
foreach loops above. The second and third loops should be dereferrenced like
so:
foreach $rel ( keys %{$blds{$org}} ) {
^^^^^^^^^^^^^
foreach $this ( keys %{$blds{$org}{$rel}} ) {
^^^^^^^^^^^^^^^^^
keys requries a hash, and you were giving it a single hash element. Is that
the only portion of the posted code you were having trouble with? In the
future, go ahead and post the error message you're getting so we know where
to start looking :) Good luck ...
Ben
------------------------------
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 V10 Issue 362
**************************************