[16394] in Perl-Users-Digest
Perl-Users Digest, Issue: 3806 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 26 06:10:40 2000
Date: Wed, 26 Jul 2000 03:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964606218-v9-i3806@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Jul 2000 Volume: 9 Number: 3806
Today's topics:
Re: or die not working <laf@gameonline.co.uk>
Re: or die not working <nospam@nospam.com>
Re: or die not working <elephant@squirrelgroup.com>
Re: Outputing CSV?? <bart.lateur@skynet.be>
Re: Outputing CSV?? (Rafael Garcia-Suarez)
Re: perl-5.6.0: Bug with "not" operator? <bart.lateur@skynet.be>
Re: popup.pm fatdaz64@my-deja.com
pos() bug? <jarjar@starwars.com>
Re: pos() bug? (Neil Kandalgaonkar)
Re: Reading and updating a file <jaurangNOjaSPAM@crosswinds.net.invalid>
Re: READING hashes eats memory!? <iltzu@sci.invalid>
Re: return value of `eval "use lib"' (Rafael Garcia-Suarez)
Re: return value of `eval "use lib"' (Eric Kuritzky)
Re: Search and delete <six4eight@NOSPAMhotmail.com>
Re: Suggestion for syntax change <iltzu@sci.invalid>
This is driving me crazy!! ivolla@my-deja.com
Re: This is driving me crazy!! <foo@bar.va>
Re: USEing a perl module <jheide@sprint.ca>
Warnings and undefs (John M. Gamble)
Re: Warnings and undefs <Peter.Dintelmann@dresdner-bank.com>
Re: What does this mean? <jaurangNOjaSPAM@crosswinds.net.invalid>
Re: When to use for and foreach? <stevenjm@telisphere.com>
Re: When to use for and foreach? (Bernard El-Hagin)
Re: Why use anonymous? <elephant@squirrelgroup.com>
Re: Why won't "use strict;" work? (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Jul 2000 09:41:48 +0100
From: "Neil Lathwood" <laf@gameonline.co.uk>
Subject: Re: or die not working
Message-Id: <964601246.2583.0.nnrp-10.c246f129@news.demon.co.uk>
"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:874s5em3vz.fsf@limey.hpcc.uh.edu...
> >> On Tue, 25 Jul 2000 19:24:49 +0100,
> >> "Neil Lathwood" <laf@gameonline.co.uk> said:
>
> > Hi Folks, excuse the lame question but.... I can't seem
> > to get the or die working. below is a quick test I tried
> > but it doesn't produce anything on the screen...any
>
> ... in the browser
>
> you mean
>
> > pointers?
>
> > #!/usr/bin/perl
>
> #!/usr/bin/perl -w
>
> use strict;
>
> use CGI ':standard';
> use CGI::Carp 'fatalsToBrowser';
>
> > print "content-type:text/html\n\n";
>
> print header;
>
> # print start_html(...);
>
> > open(TEST, "./somat/somat.txt") or die "Error:- $!";
> > @test = <TEST>; close(TEST);
>
> print end_html;
>
> Now die will output to the browser if possible.
>
> perldoc CGI
> perldoc CGI::Carp
>
> hth
> t
> --
> "With $10,000, we'd be millionaires!"
> Homer Simpson
Thanks for the answers Mark and Tony, i will give them a try....
Neil
------------------------------
Date: 26 Jul 2000 09:22:40 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: or die not working
Message-Id: <8lmal0$klo$1@216.155.32.193>
In article <397de240.b9c$39@news.op.net>, mjd@plover.com (Mark-Jason
Dominus) wrote:
| The error message is going into your server's error log or somewhere
| else that you don't want.
|
| Look into using the CGI::Carp module. Try adding
|
| use CGI::Carp 'fatalsToBrowser';
I agree with this..
| near the top of your program. If that doesn't work, try adding
|
| BEGIN { open STDERR, ">&STDOUT" }
|
| instead. This will redirect the error stream to go to the browser.
but this has me somewhat confused.. is there a spot in the
perlfaq/perldocs that deals with redirecting output ?
reason I'm confused is as to why you used the & up there. :)
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Wed, 26 Jul 2000 10:04:25 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: or die not working
Message-Id: <MPG.13e95503221cf1f698968d@news>
The WebDragon writes ..
>In article <397de240.b9c$39@news.op.net>, mjd@plover.com (Mark-Jason
>Dominus) wrote:
> | near the top of your program. If that doesn't work, try adding
> |
> | BEGIN { open STDERR, ">&STDOUT" }
> |
> | instead. This will redirect the error stream to go to the browser.
>
>but this has me somewhat confused.. is there a spot in the
>perlfaq/perldocs that deals with redirecting output ?
>
>reason I'm confused is as to why you used the & up there. :)
it's UNIX shell parlance meaning that the text following is to be
treated as a FILEHANDLE (or if numeric as a file descriptor) .. commonly
referred to as 'duping'
a brief rundown can be seen in perlfaq8 with the following
perldoc -q STDERR
an in depth discussion can be seen in the "Obscure Open Tricks" section
of
perldoc perlopentut
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 26 Jul 2000 09:37:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Outputing CSV??
Message-Id: <s2ctns4pqum2nbrj2li8pvasb8n1h4vjae@4ax.com>
Rand wrote:
>Everything works great except when they chose CSV, the browser suggests the
>file name script_name.cgi requiring the users to change it to somthing.csv.
>Any ideas how to fix this?
Try adding a "/filename.csv" at the end of your URL. Unless if you're on
IIS, it will always work. It is *supposed* to work, but MS broke the
standard (and claim it's for "security reasons", while there is no risk
at all, and they let the door wide open in so many other places).
Like this: script url:
http://wwww.yourserver.invalid/path/to/thescript.cgi
Make the link:
http://wwww.yourserver.invalid/path/to/thescript.cgi/thefile.csv
Change the ".csv" for the link into ".htm" or ".html" if you want output
HTML. You can make your script decide between the two formats, based
upon this URL. Check $ENV{PATH_INFO}.
--
Bart.
------------------------------
Date: Wed, 26 Jul 2000 10:04:08 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Outputing CSV??
Message-Id: <slrn8nte63.767.rgarciasuarez@rafael.kazibao.net>
Bart Lateur wrote in comp.lang.perl.misc:
>Rand wrote:
>
>>Everything works great except when they chose CSV, the browser suggests the
>>file name script_name.cgi requiring the users to change it to somthing.csv.
>>Any ideas how to fix this?
>
>Try adding a "/filename.csv" at the end of your URL. Unless if you're on
>IIS, it will always work. It is *supposed* to work, but MS broke the
>standard (and claim it's for "security reasons", while there is no risk
>at all, and they let the door wide open in so many other places).
>
>Like this: script url:
>
> http://wwww.yourserver.invalid/path/to/thescript.cgi
>
>Make the link:
>
> http://wwww.yourserver.invalid/path/to/thescript.cgi/thefile.csv
Alternatively, you can use those headers in your HTTP response:
Content-Type: text/csv
Content-Disposition: attachment; filename=thefile.csv;
Content-Description: thefile.csv;
--
Rafael Garcia-Suarez
------------------------------
Date: Wed, 26 Jul 2000 09:11:59 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl-5.6.0: Bug with "not" operator?
Message-Id: <9oatnsconvq6majri5vgc359h9cst8k5bm@4ax.com>
mike@excite.com () wrote:
>I think this glosses over an important point. The operators not, and,
>and or have a different precedence from !, &&, and ||, respectively.
>
>not ($a) or $b; # not has a HIGHER precendence than or
>
>SHOULD be different from:
>
>not ($a) || $b; # not has a LOWER precedence than ||
>
>(where $a is a non-trivial expression that needs parens around it)
>
>That's the whole point of mixing the words and the symbols. Parens
>shouldn't change that.
Bogus.
There is NO REASON why a unary operator should be different from a
function. A unary operator IS a function. So, it should act like one.
Any other behaviour, like the one you propone, is only confusing.
--
Bart.
------------------------------
Date: Wed, 26 Jul 2000 09:33:47 GMT
From: fatdaz64@my-deja.com
Subject: Re: popup.pm
Message-Id: <8lmb9s$7v6$1@nnrp1.deja.com>
In article <397DCB8A.CF8FB23E@scanlaser.nl>,
Bert IJff <bert@scanlaser.nl> wrote:
>
>
> fatdaz64@my-deja.com wrote:
> >
> > Hi Folks
> >
> > I am trying to get a piece of perl tk code working and I am running
> > into a problem with a "require popup.pm". I have searched Active
State
> > and CPAN for this module but I can't find any reference to it.
> >
> > Can anybody shed any light on this?
>
> Darren,
>
> I didn't find a "require popup.pm" in any of my (standard) Tk modules.
> Did you write this perl tk code yourself or did you download it,
> and possibly didn't download all the files?
>
> hth
> Bert
>
Hi Bert, thanks for the reply.
The answer to your question is "neither". I have inherited a piece of
tk code at one of my customers. The code was written by a contractor
who has subsequently disappeared off the face of the earth. I am
reliably informed that it did run OK some 12 months ago on 1 PC which
has since been completely rebuilt. When I run it it keeps crapping out
(understandably) on this "require popup.pm" statement.
Any ideas?
Cheers
Darren
> >
> > Cheers
> >
> > Darren
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 26 Jul 2000 00:52:06 -0400
From: "The Binskter" <jarjar@starwars.com>
Subject: pos() bug?
Message-Id: <8llqrb$b6k$1@slb0.atl.mindspring.net>
I have written a small piece of code to extract some info from a .html page.
The information comes from a comment
<!-- and --> within the page. If I write out the code in the main procedure
I get the correct information, if I use it in a sub, then I get nothing.
pos returns nothing. The code is supposed to return each position that the
comment starts...
Here is the code:
$strSearch =~ m/<!--/g;
while (pos($strSearch))
{
push (@strStart,pos($strSearch));
$strSearch =~ m//;
}
again, when I put the exact same code within a sub, it finds the match, but
for some reason pos() does not return any values.
Any help?
TIA,
The Binkster
------------------------------
Date: Wed, 26 Jul 2000 08:56:31 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: pos() bug?
Message-Id: <8lm8n4$f35$1@localhost.localdomain>
In article <8llqrb$b6k$1@slb0.atl.mindspring.net>,
The Binskter <jarjar@starwars.com> wrote:
>I have written a small piece of code to extract some info from a .html page.
>The information comes from a comment
><!-- and --> within the page. If I write out the code in the main procedure
>I get the correct information, if I use it in a sub, then I get nothing.
>pos returns nothing. The code is supposed to return each position that the
>comment starts...
>
>Here is the code:
>
> $strSearch =~ m/<!--/g;
> while (pos($strSearch))
> {
> push (@strStart,pos($strSearch));
> $strSearch =~ m//;
> }
My guess is that you did this:
search($foo);
sub search { # DIVE, DIVE, DIVE
my ($x) = @_;
while (pos($x)) {
# ...
}
}
Of course, $x is a new copy of $foo, so its pos() is empty.
I think you are hoping that with m// you can initialize your subroutine
in a sneaky way. This is making your logic a bit convoluted and fragile.
Why not do this?
my @positions = allpos("fie fie foe fum", qr/f/);
sub allpos {
my ($x, $regex) = @_;
my @p;
while ($x =~ m/$regex/g) {
push @p, pos($x);
}
return @p;
}
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Wed, 26 Jul 2000 00:14:11 -0700
From: Taurean <jaurangNOjaSPAM@crosswinds.net.invalid>
Subject: Re: Reading and updating a file
Message-Id: <29bb6a0e.e683f898@usw-ex0108-061.remarq.com>
Could we see the relevant code?
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: 26 Jul 2000 09:13:09 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: READING hashes eats memory!?
Message-Id: <964602520.22591@itz.pp.sci.fi>
In article <slrn8ns4gd.vcg.abigail@alexandra.foad.org>, Abigail wrote:
>Ilmari Karonen (iltzu@sci.invalid) wrote on MMDXX September MCMXCIII in
><URL:news:964559802.25515@itz.pp.sci.fi>:
>##
>## while (my ($src, $src_v) = each %cell) {
>## while (my ($dst, $dst_v) = each %$src_v) {
>## my $i = $dst_v->{packets};
>## # ...
>## }
>## }
>
>Perhaps. But maybe you want to traverse the elements in order, and sorting
>the keys can be very unwieldy. 2**20 keys is only a fraction of the total
>possible keys, but one hell of a lot of keys to sort.
The original code didn't sort them, so the issue is rather academic.
>When dealing with huge amounts like this, the Perl datastructures break
>down, and you'll need something else. Depending on what exactly you want,
>perhaps PDL or Math::Pari can work, but I don't know how whether they
>have support for sparse datastructures.
I should hope they do, it's not a particularly unusual requirement.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Wed, 26 Jul 2000 06:57:55 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: return value of `eval "use lib"'
Message-Id: <slrn8nt38u.v45.rgarciasuarez@rafael.kazibao.net>
Sweth Chandramouli wrote in comp.lang.perl.misc:
> I've got a script that has a user-configurable parameter
>@INC_DIRS that describes the location of directories in which to look for
>modules specific to this script; after doing some checks to make sure that
>the modules in the specified directories meet certain criteria, I want to
>add the contents of @INC_DIRS to @INC, and then invoke the relevant modules
>via "use" statements. I'm doing the @INC change with the following line:
>
>eval "use lib qw(@INC_DIRS)";
>
> , and everything works fine--except when I try to make sure
>that the eval succeeded. I normally wouldn't check the exit status of
>a command like that, but I was having some problems with the equivalent
>eval+use that I was doing subsequently to invoke the modules in @INC_DIRS,
>so I did something along the lines of
>
>eval "use lib qw(@INC_DIRS)" or
> die "Couldn't use libs in \@INC_DIRS!";
>
> , which would die every time. Some more testing solved the
>original problem, which turned out to not be with this eval at all; some
>subsequent tests revealed that I was being misled by this die into thinking
>that the eval here was failing, even though it was succeeding.
It appears that the 'use' implies a BEGIN. The return value is thus always
undefined (if I am understanding correctly the workings of BEGIN).
So you could use:
eval "require lib; import lib qw(@INC_DIRS);";
But this doesn't solve your problem. Why? Because the import method
in lib.pm does not return a success status (at least in perl
5.005_03). But you could patch it.
Note that the error cases of lib::import are :
* no argument to import
* a file is passed to import.
It does not test for existence of directories.
This is probably not what you want.
My suggestion is: implement the tests yourself in your script.
--
Rafael Garcia-Suarez
------------------------------
Date: 26 Jul 2000 07:47:00 GMT
From: kuritzky@math.berkeley.edu (Eric Kuritzky)
Subject: Re: return value of `eval "use lib"'
Message-Id: <8lm51k$bpo$1@agate.berkeley.edu>
In article <P3tf5.13404$eS6.234300@news1.rdc1.md.home.com>,
Sweth Chandramouli <sweth+perl@gwu.edu> wrote:
|.... I'm doing the @INC change with the following line:
|
|eval "use lib qw(@INC_DIRS)";
|
| , and everything works fine--except when I try to make sure
|that the eval succeeded...
use doesn't return a value, so eval doesn't, either. On the other
hand, eval _does_ set $@ when something goes wrong with the
evaluation, so you can have:
eval "use lib qw(@INC_DIRS)";
die "Couldn't use libs in \@INC_DIRS!" if $@;
or (maybe better):
eval "use lib qw(@INC_DIRS)";
die $@ if $@;
The documentation of $@ in perlvar is somewhat misleading: it says
that $@ isn't set if the statement merely "[fails] in the normal
fashion", but it appears to be set whenever there's a problem with a
use statement.
--Eric Kuritzky
perl -e 'print "Just a wannabe Perl hacker\n"'
------------------------------
Date: Wed, 26 Jul 2000 08:49:28 GMT
From: "Eelke Kleijn" <six4eight@NOSPAMhotmail.com>
Subject: Re: Search and delete
Message-Id: <sCxf5.2978$Gd1.31722@Typhoon.bART.nl>
I'm sorry I'll try to do that in the future.
I found out I have to use print @array; instead of
print "@array";
L8r
Eelke
"Larry Rosler" <lr@hpl.hp.com> schreef in bericht
news:MPG.13e787a1ac90824898abe8@nntp.hpl.hp.com...
> In article <szhf5.2374$Gd1.28186@Typhoon.bART.nl> on Tue, 25 Jul 2000
> 14:34:00 GMT, Eelke Kleijn <six4eight@NOSPAMhotmail.com> says...
> > Never mind stoopid question I found it out already
> >
> > <SNIP>
>
> Then why didn't you share the answer with those who read your post, so
> they might avoid the same problem in the future?
>
> perlfaq5: "Why do I get weird spaces when I print an array of lines?"
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: 26 Jul 2000 09:06:16 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Suggestion for syntax change
Message-Id: <964600656.16864@itz.pp.sci.fi>
In article <slrn8ns0ih.vcg.abigail@alexandra.foad.org>, Abigail wrote:
>Ilmari Karonen (iltzu@sci.invalid) wrote on MMDXX September MCMXCIII in
><URL:news:964557132.20799@itz.pp.sci.fi>:
>,,
>,, $ perl -le '$_ = 0; 0 || do {print} while ++$_ < 3;'
>,, 0
>,, 1
>,, 2
>,,
>,, As far as perl is concerned, this one is identical to the previous
>,, example. Really identical. The optimizer evaluates the constant part
>,, of the expression at compile time, producing the exact same bytecode.
>
>That is a bug.
Granted, but that bug only exists because of the kluge that is needed
to make "do BLOCK while EXPR" act differently from "EXPR while EXPR",
even though the former is syntactically a subset of the latter.
>,, And *this* is why I oppose, nay, loathe the idea of .. being magical
>,, inside list slices.
>
>Because of a *bug* in something completely different? That doesn't make
>any sense at all.
Not because of the bug itself, but because the change would create a
similar situation prone to similar bugs and confusion. It would have
to sniff out (LIST)[EXPR .. EXPR] and treat it differently from the
general case (LIST)[LIST], even though LIST may in general contain the
.. operator. And what about (LIST)[LIST, EXPR .. EXPR, LIST], which
one _would_ expect to be magical..?
I've already suggested an alternative solution which would not just
avoid any such dark magic, but would also break no existing code.
IMHO the magic .. should be filed away in the "good ideas that don't
generalize properly" -folder and forgotten.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The screwdriver *is* the portable method." -- Abigail
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Wed, 26 Jul 2000 07:41:17 GMT
From: ivolla@my-deja.com
Subject: This is driving me crazy!!
Message-Id: <8lm4mt$3cs$1@nnrp1.deja.com>
I am VERY new to Perl and so far am up to speed
except one thing. When I try to execute a script
it shows up for about 1/2 a second then it
disappears. I downloaded the latest version from
perl.com and it appears that the the programs I
am writing (print "hello" etc.) are working, but
they go bye so quick I can barely tell. Has
anyone else had this problem or is this correct.
I am using windows 98, Perl 5
Any help would be greatly appreciated!!!
Thanks in advance.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 26 Jul 2000 10:07:01 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: This is driving me crazy!!
Message-Id: <397E9C25.C8D54230@bar.va>
ivolla,
ivolla@my-deja.com wrote:
> I am VERY new to Perl and so far am up to speed except one thing.
> When I try to execute a script it shows up for about 1/2 a second
> then it disappears. I downloaded the latest version from perl.com
> and it appears that the the programs I am writing (print "hello"
> etc.) are working, but they go bye so quick I can barely tell.
> Has anyone else had this problem or is this correct. I am
> using windows 98, Perl 5
Truuuuuuuuuue! I had this problem tooooooo! My solution is
Start->Programs->Command Prompt
and then use it like a
deprecated-old-text-based-non-ActiveX-too-Unix-like-where-is-my-animated-pointer?-TTY-shell...
Try, for example, to type in the line
C:\PERL\BIN> perl hello.pl
and it will work, remaining the IT-greeting on the screen as long as you
want.
An alternative, of course, is to use a web server and to write CGI's
in Perl...
> Any help would be greatly appreciated!!!
Only pre-holiday humor, don't care. ;)
Best regards,
Marco
------------------------------
Date: Tue, 25 Jul 2000 21:50:59 -0700
From: "Glen Heide" <jheide@sprint.ca>
Subject: Re: USEing a perl module
Message-Id: <J8uf5.686$fV5.18191@newscontent-01.sprint.ca>
Hey hey now, Tad answered my question that I can't use an uninstalled
module... so there's no need for an immature arguments ;)
(don't even think about holding your breath)
If you want to, check my new posting "install"
YOU CAN'T MISREAD THAT ONE!!! =P
--
Yours Truly,
Glen Heide
------------------------------
Date: 26 Jul 2000 04:37:06 GMT
From: jgamble@ripco.com (John M. Gamble)
Subject: Warnings and undefs
Message-Id: <8llpti$rth$1@gail.ripco.com>
What is - or should be - the proper category to disable warnings for
joining lists with undefs in them? For example (with warnings):
$ p56 -we '@x = (1, undef, 3); print join(":", @x), "\n";'
Use of uninitialized value in join at -e line 1.
1::3
(p56 is a symbolic link, we haven't made the official switch-over yet to
version 5.6.0).
I frequently have undefs in my lists (for legitimate reasons), and i
obviously don't want to pester the user with warnings. I also only want
to disable the warnings that affect this and no other situation.
Putting 'no warnings' in works:
$ p56 -we 'no warnings; @x = (1, undef, 3); print join(":", @x), "\n";'
1::3
but it could also cover up something that i need to be warned about. So
i'm looking for the correct category, but it seems that *every* category
covers up the warning:
$ p56 -we 'no warnings qw(io); @x = (1, undef, 3); print join(":", @x), "\n";'
1::3
$ p56 -we 'no warnings qw(y2k); @x = (1, undef, 3); print join(":", @x), "\n";'
1::3
Hmm, 'io' and 'y2k' both cover joining undefs in the join operator?
I know that i could just put extra braces around every statement that
has a join in it, and plunk in the 'no warnings;' statement. But this
seems to be more work than should be needed.
Any thoughts?
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
--
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, '227,
any and all unsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500
US. E-mailing denotes acceptance of these terms.
------------------------------
Date: Wed, 26 Jul 2000 09:28:58 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Warnings and undefs
Message-Id: <8lm3v5$f5o1@intranews.dresdnerbank.de>
Hi,
John M. Gamble schrieb in Nachricht <8llpti$rth$1@gail.ripco.com>...
>
>What is - or should be - the proper category to disable warnings for
>joining lists with undefs in them? For example (with warnings):
warnings can be swichted on/off using $^W.
Thus try
{
$^W = 0; # disable warnings in this code block
<... your code>
}
Best regards,
Peter Dintelmann
------------------------------
Date: Wed, 26 Jul 2000 01:05:17 -0700
From: Taurean <jaurangNOjaSPAM@crosswinds.net.invalid>
Subject: Re: What does this mean?
Message-Id: <06f84faa.f3d9073c@usw-ex0108-061.remarq.com>
Thanks Graham, you're right.
* Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Wed, 26 Jul 2000 05:39:43 GMT
From: Steven May <stevenjm@telisphere.com>
Subject: Re: When to use for and foreach?
Message-Id: <397E7963.3338DF27@telisphere.com>
Abigail wrote:
>
> Reini Urban (rurban@sbox.tu-graz.ac.at) wrote on MMDXX September MCMXCIII
> in <URL:news:397e202d.213784325@news>:
> )) Jim Cook wrote:
> )) >What are the opinions here? When would it be better to use 'for' or
> )) >'foreach?'
> ))
> )) trust the docs.
>
> 'for' is more than twice as fast [1] as 'foreach'.
>
> [1] to type
>
> Abigail
Ahhh... when????...
I always thought they were pretty close to the same, given
the same basic operation. This one got me going a bit, so
I ran some benchmarks on it...
First a quick and dirty:
sub do_for {
my @list = qw(1 2 3 4 5 6 7 8 9);
my $ct;
for(@list){ $ct += $_; }
}
sub do_foreach{
my @list = qw(1 2 3 4 5 6 7 8 9);
my $ct;
foreach(@list){ $ct += $_; }
}
Benchmark: timing 100000 iterations of FOR, FOREACH...
FOR: 12 wallclock secs (13.57 usr + 0.00 sys = 13.57 CPU)
FOREACH: 12 wallclock secs (12.79 usr + 0.00 sys = 12.79 CPU)
Then try to speed it up with a 'global' list...
use vars ( @list );
@list = = qw(1 2 3 4 5 6 7 8 9);
sub do_for {
my $ct;
for(@list){ $ct += $_; }
}
sub do_foreach{
my $ct;
foreach(@list){ $ct += $_; }
}
Benchmark: timing 100000 iterations of FOR, FOREACH...
FOR: 3 wallclock secs ( 2.64 usr + 0.00 sys = 2.64 CPU)
FOREACH: 3 wallclock secs ( 2.69 usr + 0.00 sys = 2.69 CPU)
Hmmmm..... creating that list was hurting a little....
Another variation...
sub do_for {
my $ct;
for(1..9){ $ct += $_; }
}
sub do_foreach{
my $ct;
foreach(1..9){ $ct += $_; }
}
Benchmark: timing 100000 iterations of FOR, FOREACH...
FOR: 4 wallclock secs ( 3.25 usr + 0.00 sys = 3.25 CPU)
FOREACH: 3 wallclock secs ( 3.13 usr + 0.00 sys = 3.13 CPU)
So.
I don't regard these numbers as showing any significant difference.
My poor ol' Win95 machine is pretty eratic at times and that's what
I ran these on. (too lazy to set them up on the linux box :-)
Am I missing something totally obvious?
I'm all ears....
Steve
------------------------------
Date: Wed, 26 Jul 2000 05:56:38 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: When to use for and foreach?
Message-Id: <slrn8nsv3r.61h.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 26 Jul 2000 05:39:43 GMT, Steven May <stevenjm@telisphere.com>
wrote:
>Abigail wrote:
>>
>> Reini Urban (rurban@sbox.tu-graz.ac.at) wrote on MMDXX September MCMXCIII
>> in <URL:news:397e202d.213784325@news>:
>> )) Jim Cook wrote:
>> )) >What are the opinions here? When would it be better to use 'for' or
>> )) >'foreach?'
>> ))
>> )) trust the docs.
>>
>> 'for' is more than twice as fast [1] as 'foreach'.
>>
>> [1] to type
>>
>> Abigail
>
<snipped silly benchmarks>
>Am I missing something totally obvious?
>
>I'm all ears....
Yeah, you're missing Abigail's joke. Read it again carefully and notice
the [1]...
Bernard
--
perl -le 'open(JustAnotherPerlHacker,"")or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'
------------------------------
Date: Wed, 26 Jul 2000 09:55:11 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Why use anonymous?
Message-Id: <MPG.13e952d8398d5c9a98968c@news>
Nobody writes ..
>In article <397CA69B.A9495E2D@west.net>, John Callender <jbc@west.net> wrote:
>>awilcox@contract.East.Sun.COM wrote:
>>>
>>> So, to recap, why would you use an anonymous hash or
>>> subroutine, as opposed to their named counterparts?
>>
>>To build multilevel data structures? Anonymous hashes, at least,
>>tend to show up there a lot.
>>
>
>Hmmm. I've built these kinds of structures before, but never thought of them
>as 'anonymous', since they were simply part of a larger structure that did
>have a name. The example that the interview twit used was a single unnamed
>hash...
ok .. well first of all they certainly are anonymous .. the references
to the structures might be named - but the structures themselves have no
name
anonymous subs can be passed in to subroutines and used as callbacks or
in classes to create closures (certainly not something you use
frequently - but when they are of use - they're REALLY useful)
but without seeing your specific example ("a single unnamed hash") -
it's difficult to know what you're talking about
how about a program where you might have a whole bunch of subroutines
that all do certain things to the values of a hash and you want to pass
a hash into each one of those routines
you could either create a named hash and pass it's reference each time
.. or you could create an anonymous hash assigning it's reference to a
scalar .. and pass that scalar into each of the routines .. here's a not
so clever example (hopefully it shows the idea that I'm trying to get at
successfully - like I said above though - it's hard to know what you're
talking about without you showing the actual example)
#!/usr/bin/perl -w
use strict;
# create an anonymous hash and assign it's reference to $h
my $h = { name => 'jason king'
, email => 'elephant@squirrelgroup.com'
, newsgroup => 'c.l.p.misc'
};
# call some stupid routines that make some modifications of the hash
stupidExpandNewsgroupsRoutine($h);
stupidCapitaliseNameRoutine($h);
# just print out for testing
print $h->{name}, "\t", $h->{newsgroup}, "\n";
sub stupidExpandNewsgroupsRoutine
{
my $hr = shift;
$hr->{newsgroup} =~ s/\bc\./comp./;
$hr->{newsgroup} =~ s/\bl\./lang./;
$hr->{newsgroup} =~ s/\bp\./perl./;
}
sub stupidCapitaliseNameRoutine
{
my $hr = shift;
$hr->{name} =~ s/\b(\w)/\u$1/g;
}
__END__
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 26 Jul 2000 01:52:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Why won't "use strict;" work?
Message-Id: <slrn8nsv5o.i8n.tadmc@magna.metronet.com>
On 25 Jul 2000 08:31:14 -0700, Petri Oksanen <Petri_member@newsguy.com> wrote:
>In article <slrn8npmf0.a3e.tadmc@magna.metronet.com>, tadmc@metronet.com says...
>
>> Controlling variable scope is first-semester CS fodder,
>> are you not a programmer?
>Do you want to limit Perl to be the personal playtoy of a bunch of CS geeks
>sitting around making theoretical solutions to theoretical CS problems?
No.
I want to know his experience level so that I will know
how to approach giving him answers.
Sheesh!
You non-geeks seem awfully touchy about stuff.
>Perl is for everyone who desires to use it.
Well yes.
I never said otherwise.
I just wanted to know what level of answer was needed!
>Your remarks are unnecessary
No, knowing your audience is very necessary to forming
a useful answer.
>and insulting to every selftaught hacker out there.
No it isn't.
I just wanted to know what level of answer was appropriate.
This is a programmer's newsgroup. A certain baseline of
fundamental knowledge is assumed.
If you do not have the expected background, then you should
say so, if you want an answer that is comprehensible to you.
>Sure, the poor guy is a total beginner and has obviously chosen a far too
>complex first project for himself, but that doesn't mean he needs to take grief
>from you or anyone else for that fact.
I did not give him grief.
I asked him what his background is, so that I could speak
to that level.
>Elitist comments like that
It is *NOT* an elitist comment.
I just wanted to answer the question at the appropriate level!!
>are not helping the community,
Golly. You've been here a whole three months and you already
know all about this community?
I see the wisdom of your sage advice.
I will take steps to ensure that I don't "not help the community"
anymore. Please step in and take up the slack so created.
So long.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3806
**************************************