[16264] in Perl-Users-Digest
Perl-Users Digest, Issue: 3676 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 15 03:05:29 2000
Date: Sat, 15 Jul 2000 00:05:12 -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: <963644711-v9-i3676@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 15 Jul 2000 Volume: 9 Number: 3676
Today's topics:
Re: ANSI Perl: No Way !!! <jjohn@cs.umb.edu>
Re: ANSI Perl: No Way !!! <callgirl@la.znet.com>
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! (Randal L. Schwartz)
Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!! <thad_brown@earthlink.net>
Re: Bug Or Feature? <kj0@mailcity.com>
Re: CGI problem, newbie, code follows.... <makarand_kulkarni@my-deja.com>
Re: different namespace for functions from a library? (jason)
Re: file endings with regexps... <lr@hpl.hp.com>
Re: file endings with regexps... (jason)
Re: filling out www froms using LWP <makarand_kulkarni@my-deja.com>
Re: Is there a better way (Multi-dimen. Arrays) <mauldin@netstorm.net>
Re: local and use strict (jason)
Re: local and use strict <lr@hpl.hp.com>
Re: local and use strict (jason)
Re: perl beautifier? (Neil Kandalgaonkar)
Re: Perl Expert? I need help! <akurczyn@usa.net>
Re: PerlScript on Win2K <mauldin@netstorm.net>
Re: PRINTing " "" " <lr@hpl.hp.com>
Running Active Perl under NT <Michael_Phipps@hotmail.com>
Re: Silly Question? (jason)
Re: The newbie question (jason)
Re: The newbie question <callgirl@la.znet.com>
Re: The newbie question <lr@hpl.hp.com>
Re: Trying to use an array as a hash value doglovers@rocketmail.com
Re: UDP / ICMP checksum generation - 1's complement sum <lr@hpl.hp.com>
Re: UDP / ICMP checksum generation - 1's complement sum <sb@muccpu1.muc.sdm.de>
Re: Upper-to-lower case problem <bart.lateur@skynet.be>
Re: what mod-perl require (jason)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 15 Jul 2000 02:30:11 GMT
From: Joe Johnston <jjohn@cs.umb.edu>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <396FCCAA.85D5A6D4@cs.umb.edu>
David Meyers wrote:
>
> jerome@activeindexing.com (Jerome O'Neil) writes:
> > "Godzilla!" <godzilla@stomp.stomp.tokyo> elucidates:
> > > Drew Simonis wrote:
> > >
> > >> "Godzilla!" wrote:
> > > (snipped trolling, harassment, personal insults)
>
> > > As with others, I will ask you to not troll
> > > and harass me. This sociopathic behavior of
>
> > It's highly entertaining, watching people poke you.
> >
> > You are our very own state machine! What can we make you
> > do next?
>
> GoTrolla has already claimed several times to have
> written perl robots. Perhaps GoTrolla itself is the
> evidence thereof. As effective as it is, I'm quite
> impressed.
Wow! See what I miss when I don't read c.l.p.m!
I'm proud that my greatest contribution to Perl
has been to provide troll fodder!
I suppose we are no more likely to see
Perl standardized than X will get a right
pull through a Christmas tree.
Mmm. Mayhap I'll crawl back to IRC :-)
--
----------------
Joe Johnston
http://aliensaliensaliens.com
------------------------------
Date: Fri, 14 Jul 2000 19:45:32 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: ANSI Perl: No Way !!!
Message-Id: <396FD04C.54DEAD6A@la.znet.com>
Joe Johnston wrote:
> David Meyers wrote:
> > Jerome O'Neil wrote:
> > > Godzilla! wrote:
> > > > Drew Simonis wrote:
> > > >> "Godzilla!" wrote:
> > > > (snipped trolling, harassment, personal insults)
(snipped)
> I'm proud that my greatest contribution to Perl
> has been to provide troll fodder!
Your greatest contribution in this article
of yours, is to inadvertently expose yourself
for the troll you are.
Godzilla!
------------------------------
Date: 14 Jul 2000 20:47:19 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <m1r98wgim0.fsf@halfdome.holdit.com>
>>>>> "NP" == NP <nvp@spamnothanks.speakeasy.org> writes:
NP> And, with the exception of Randal, perhaps, we wear pants to work.
Hmm. Last time I checked, I *always* wear pants to work.
NP> Let's not go too overboard, okay? We're people just like
NP> everybody here (except "Ganesha", of course). We appreciate it!
Right. Genuflecting in front of me only makes me more embarassed. I
appreciate people appreciating me, but that's not why I do what I do.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 14 Jul 2000 21:50:04 -0600
From: Thad Brown <thad_brown@earthlink.net>
Subject: Re: ATTENTION PERL MACHOES!!!!!!!!!!!!!!!!!!!
Message-Id: <396FDF6C.E7C7BF1D@earthlink.net>
>
> ASIDE FROM YOUR CLAIMS OF SELFLESSNESS AND SACRIFICE, WHAT HAVE YOU
> DONE FOR THE PERL COMMUNITY TODAY? HAND SHAKING, BEER MOOCHING,
> DONATION TAKING, CROONING AND BEING FRIENDLY ON comp.lang.perl.misc
> DOES NOT COUNT. EXCLUDING THOSE THINGS, WHAT HAVE YOU DONE MISTER
> RANDALLLL?
>
> IF comp.lang.perl.misc IS A REPRESENTATIVE OF THE PERL COMMUNITY THEN
> THE PERL COMMUNITY IS A SELFISH, SELF-SERVING AND BOORISH ONE. OH, MAY
> YOU ALL FEAR THE WRATH OF GANESH.
It's a miracle!! Your English came back to you. Now I need a root beer.
------------------------------
Date: 14 Jul 2000 22:08:29 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: Bug Or Feature?
Message-Id: <8koh2t$fr5$1@panix3.panix.com>
[I saw the light 30 seconds after posting
and I cancelled the post. To those who got
it nonetheless, please disregard it.]
------------------------------
Date: Fri, 14 Jul 2000 18:27:11 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Russell Smallwood <rsmallwood@mindspring.com>
Subject: Re: CGI problem, newbie, code follows....
Message-Id: <396FBDEF.E9B1551E@my-deja.com>
> $title=$wp->param ('titile');
$title= $wp->param ('title');
>
> print >>EOF;
print <<EOF;
--
------------------------------
Date: Sat, 15 Jul 2000 01:29:51 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: different namespace for functions from a library?
Message-Id: <MPG.13da5bd998ce90979896b7@news>
Alex T. wrote ..
>I had a script, which was working just right:
>
>my %Replacements;
>$Resplacements{TEST} = '<p>test</p>;
you haven't said how this breaks .. what error you receive .. so I'm
just going from your code - the line above is missing a single quote -
and that must be throwing everything else out of whack
>require "/some/path/to/asp.pl";
perldoc -f require
>my %Replacements;
>$Resplacements{TEST} = '<p>test</p>;
>....
>&displayPage('apage.html');
>
>If I remove "my" from "my %Replacements" it works ok again. Could
>someone explain what difference it makes? Does it have anything to do
>with namespaces? I thought functions from a library are imported into
>the main namespace.., so "my ..." should have worked just fine.
your problem is very unclear .. you haven't provided any code from
asp.pl to show how you've set that library up .. but whatever your
problem - it's almost certainly answered by reading the docs
perldoc perlmod
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 14 Jul 2000 18:34:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file endings with regexps...
Message-Id: <MPG.13d95f6cb00ac1eb98abd0@nntp.hpl.hp.com>
In article <MPG.13da542b4cc8ae549896b5@news> on Sat, 15 Jul 2000
00:57:01 GMT, jason <elephant@squirrelgroup.com> says...
> Michael D. Hofer wrote ..
> >jason wrote:
...
> >> my $ending = substr $path, rindex( $path, '.') - length($path) +1;
> >
> >Okay, but why not
> >
> >my $path = "/mitglied/sd.fjn.sdf.html";
> >my $ending = (split '\.',$path)[-1];
> >
> >??
...
> the reason is a purist one .. speed .. get out Benchmark and you'll see
> how far pedantry can go ;)
>
> but in seriousness - something that could possibly be operating on a
> whole bunch of input strings (like traversing a directory tree) this is
> a situation where I would always go with the quickest solution
>
> the substr/rindex/length solution is over 2.5 times quicker than a split
> solution .. and almost ten times quicker than a regex based solution
Even faster if you leave out the unnecessary length():
my $ending = substr $path, 1 + rindex $path, '.';
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 15 Jul 2000 01:51:54 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: file endings with regexps...
Message-Id: <MPG.13da6107763104e29896bb@news>
Larry Rosler wrote ..
>In article <MPG.13da542b4cc8ae549896b5@news> on Sat, 15 Jul 2000
>00:57:01 GMT, jason <elephant@squirrelgroup.com> says...
>> Michael D. Hofer wrote ..
>> >jason wrote:
>
>...
>
>> >> my $ending = substr $path, rindex( $path, '.') - length($path) +1;
>> >
>> >Okay, but why not
>> >
>> >my $path = "/mitglied/sd.fjn.sdf.html";
>> >my $ending = (split '\.',$path)[-1];
>> >
>> >??
>
>...
>
>> the reason is a purist one .. speed .. get out Benchmark and you'll see
>> how far pedantry can go ;)
>>
>> but in seriousness - something that could possibly be operating on a
>> whole bunch of input strings (like traversing a directory tree) this is
>> a situation where I would always go with the quickest solution
>>
>> the substr/rindex/length solution is over 2.5 times quicker than a split
>> solution .. and almost ten times quicker than a regex based solution
>
>Even faster if you leave out the unnecessary length():
>
> my $ending = substr $path, 1 + rindex $path, '.';
hee hee .. thanks - my brain was in backwards mode .. now it's 3.5 times
quicker (than the split solution)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 14 Jul 2000 18:21:08 -0700
From: Makarand Kulkarni <makarand_kulkarni@my-deja.com>
To: Gorby <gorbeast@SPAMSUCKS.subduction.org>
Subject: Re: filling out www froms using LWP
Message-Id: <396FBC84.E22FF81A@my-deja.com>
>
> 2) Suppose I want to fill out a form with my name and email address on
> the web automatically. Do I send the post request to the page with the
> actual form, or do I send it to the "confirmation" page, as a URL of the
You should sent it to the script that is going to accept
your form input. On the browser right click and see
the HTML source. Look for lines like
<FORM METHOD=GET ACTION="http://www.xx.yy.edu/cgi-bin/post-query">
The ACTION=script tag will determine where the form input
will be sent. You should use LWP to send form input
there.
------------------------------
Date: Sat, 15 Jul 2000 02:48:18 GMT
From: James Mauldin <mauldin@netstorm.net>
Subject: Re: Is there a better way (Multi-dimen. Arrays)
Message-Id: <396FD03D.C3CA5C81@netstorm.net>
Maybe I misunderstand what you're trying to do, but wouldn't the following be a
better way to accomplish your while / do loops?
for (@data) {
s/\s+$/\n/;
/^DATE:/ && ++$stepcounter || push @{$steps[$stepcounter]}, $_;
}
This assumes that you know for sure that there is whitespace at the end of each
line, otherwise you'd have to use separate statement:
s/\s+$//;
$_ .= "\n";
-- Jim
John Fortin wrote:
> > > while (@data) {
> > > do {
> > > $data[0] =~ s/\s+$//;
> > > $data[0] = $data[0]."\n";
> > > push @{$steps[$stepcounter]}, $data[0];
> > > shift @data;
> > > } until (!@data || $data[0] =~ /^DATE:/);
> > > $stepcounter++;
> > > }
> > >
------------------------------
Date: Sat, 15 Jul 2000 01:42:32 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: local and use strict
Message-Id: <MPG.13da5ed557c176009896b9@news>
Brendon Caligari wrote ..
><nobull@mail.com> wrote in message news:u9itu8u19l.fsf@wcl-l.bham.ac.uk...
>
>> However, in general you should avoid doing this. local() is a powerfull
>> tool in the cases where it is the right tool. It is however not often
>> the right tool.
>
>I admit that while I appreciate it's existence, I couldn't really conceive
>any particular use for it. I classify it together with taboos like 'gotos'.
you just haven't come across a situation that it was made for yet - or
don't understand Perl's special variables .. the following situation is
perfect for local to be used
my @input = ();
open INPUT, "blah" or die "etc";
{
local $/;
@input = <INPUT>;
}
# continue program
>I'm still trying to 'accept' previousy frowned upon concepts such
>as breaking straight out of a number of nested loops
frowned upon by whom ? .. breaking out of a loop is a well tested and
supported language feature than lends itself to good design
>> Note that "for", "map" and "grep" implicity localise $_, you don't
>> need to do it explicitly.
>
>Aha. So, really and truly it's irrelevant what gets passed to, say,
>a foreach iteration in fact being 'localised'.
>
> #!/usr/bin/perl -w
> use strict;
> my( $s );
> $s = "Whatever";
> print("Entry Value = $s\n");
> foreach $s (1..5) { print("Interim Value = $s\n"); }
> print("Exit Value = $s\n");
> exit(0);
>
>..yeah...in fact it gave "Whatever 1 2 3 4 5 Whatever"
from a linguistic view - there's nothing wrong with the above .. from a
human understanding view - it's rarely advantageous to use the one
variable for two different purposes .. the above would be better written
as
#!/usr/bin/perl -w
use strict;
my $value = "Whatever";
print("Entry Value = $value\n");
foreach my $count (1..5) { print("Interim Value = $count\n"); }
print("Exit Value = $value\n");
exit(0);
__END__
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 14 Jul 2000 23:22:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: local and use strict
Message-Id: <MPG.13d9a3172184756498abd2@nntp.hpl.hp.com>
In article <MPG.13da5ed557c176009896b9@news>, elephant@squirrelgroup.com
says...
...
> you just haven't come across a situation that it was made for yet - or
> don't understand Perl's special variables .. the following situation is
> perfect for local to be used
>
> my @input = ();
> open INPUT, "blah" or die "etc";
> {
> local $/;
> @input = <INPUT>;
> }
>
> # continue program
Hmmm. Not the finest example. Why would one want to create an array
comprising one element, a string with the entire contents of the file?
For splitting a file into an array, you need a better value for $/ than
undef.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 15 Jul 2000 06:42:33 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: local and use strict
Message-Id: <MPG.13daa52bb23b10e79896bf@news>
Larry Rosler wrote ..
>In article <MPG.13da5ed557c176009896b9@news>, elephant@squirrelgroup.com
>says...
>
>...
>
>> you just haven't come across a situation that it was made for yet - or
>> don't understand Perl's special variables .. the following situation is
>> perfect for local to be used
>>
>> my @input = ();
>> open INPUT, "blah" or die "etc";
>> {
>> local $/;
>> @input = <INPUT>;
>> }
>>
>> # continue program
>
>Hmmm. Not the finest example. Why would one want to create an array
>comprising one element, a string with the entire contents of the file?
oops .. wrote it too fast .. should have read
my $input = '';
open INPUT, "blah" or die "etc";
{
local $/;
$input = <INPUT>;
}
# continue program
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Sat, 15 Jul 2000 05:41:27 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: perl beautifier?
Message-Id: <8kot66$s0p$1@localhost.localdomain>
In article <396e0364@news.victoria.tc.ca>,
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
>Whether this is a beautifier or not depends on how ugly the original code
>is, plus it loses comments.
>
>perldoc B::Deparse
>
>perl -MO=Deparse your_script.pl
Deparse also optimizes away things that will never be reached. Not a good
thing while you are still developing.
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: Sat, 15 Jul 2000 00:15:02 -0500
From: "Alejandro Kurczyn" <akurczyn@usa.net>
Subject: Re: Perl Expert? I need help!
Message-Id: <396ff2b4_1@excalibur.gbmtech.net>
Assuming the regexp works, what is the difference between it and:
$a =~ s/\s+//g;
$a=substr($a,0,8);
Is it better to use regexps if there is already a function to do it?
Regards,
Alejandro
"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> escribió en el mensaje
news:slrn8mu4bn.9rf.bernard.el-hagin@gdndev25.lido-tech...
> On Fri, 14 Jul 2000 13:02:42 GMT, Sylvain2k <sylvain2k@sympatico.ca>
wrote:
> >(sorry... I'm a french canadian so my english is bad)
> >
> >Hi,
> >
> >I have a little problem. there it is:
> >
> >$a = "My name is Sylvain";
> >
> >I want to delete ALL spaces in this variable.
> >I only want the first 8 caracters of the result.
> >
> >How can I do that?
>
> __________________
> #!/usr/bin/perl -w
> use strict;
>
> my $a = "My name is Sylvain";
> $a =~ s/\s+//g;
> $a =~ s/^(.{8})/$1/;
>
> print $a;
> __________________
>
> That's just one of 1234283273122 ways of doing this in Perl.
>
> Bernard
> --
> perl -e'@x=(3,2,4,1,3,2,1,3,1,3,2,3,3,2,3,0,0,1,2,1,1,1,4,1,2,1,1,2,2,1,
> 2,1,2,1,2,1,2,1,1,1,2,1,0,0,3,2,3,2,3,2,1,1,1,1,1,2,4,2,3,2,1,2,1,0,0,1,
> 2,1,1,1,4,1,2,1,1,1,2,2,1,1,4,1,1,1,2,1,1,1,2,1,0,0,3,2,4,1,1,2,1,1,1,3,
> 1,1,1,4,1,1,1,2,1,1,3,0,0);sub x{print q x$xx$_;print q x x x shift@x};#
> while(defined($_=shift @x)){s o0o\no;$_!=0?x:print}' #Symmetry yrtemmyS#
------------------------------
Date: Sat, 15 Jul 2000 03:20:50 GMT
From: James Mauldin <mauldin@netstorm.net>
Subject: Re: PerlScript on Win2K
Message-Id: <396FD7DC.6D70E376@netstorm.net>
Look at the ActiveState PerlScript documentation for some examples of
client-side PerlScript to give you some ideas. I have a couple of
client-side scripts that do some form handling and printing, but that's
as far as I've gotten. The whole field is woefully under-documented,
and M$ doesn't have any incentive to help out.
Good luck and Let me know what you find.
--Jim
danno6000@my-deja.com wrote:
> Has anybody successfully used PerlScript (from
> ActiveState) with IIS5 and Active Server Pages on
> Win2K?
>
> I installed ActivePerl 5.6 build 615 and it works
> fine from the command line, but I can't get
> PerlScript to work from ASP's. I was logged in
> as "administrator" when I did the install. The
> install was fresh, meaning there wasn't an old
> version of ActivePerl on the machine.
>
> Thanks,
> Dan
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Fri, 14 Jul 2000 18:24:30 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: PRINTing " "" "
Message-Id: <MPG.13d95d2b446a6feb98abce@nntp.hpl.hp.com>
In article <8kob8t$fo3$1@provolone.cs.utexas.edu> on 14 Jul 2000
19:29:17 -0500, Logan Shaw <logan@cs.utexas.edu> says...
> In article <MPG.13d92870fc6a777598abcb@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
> >Why tolerate them? Golf, of course! A string containing exactly one
> >quote is one stroke shorter if the string is backslashed than if
> >alternate quote characters are used.
> >
> > "\"\n"
> >
> > qq("\n)
>
> Um, how about this?
>
> '"'
>
> That's the shortest possible way to write a string that contains
> exactly one quote. (Well, o.k., it's not -- it's the shortest
> way to write such a string as a literal.)
>
> Of course,
>
> '"\n'
>
> doesn't work out too well if you want to do that...
Now you know why that "\n" just happened to sneak into my example.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 15 Jul 2000 23:14:06 +1000
From: "Michael Phipps" <Michael_Phipps@hotmail.com>
Subject: Running Active Perl under NT
Message-Id: <8kodu0$82a$1@gnamma.connect.com.au>
I am having problems getting Active Perl running on my NT Box. I have done
it before, and there is something extra you have to do with registry
settings before you are able to call .cgi scripts on your website.
Does anyone have this info?
Michael Phipps
------------------------------
Date: Sat, 15 Jul 2000 01:21:51 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Silly Question?
Message-Id: <MPG.13da59fae2ef9a49896b6@news>
Jürgen Exner wrote ..
>"Richard Cole" <r.cole@gu.edu.au> wrote in message
>news:396EBADE.E0B17DD@gu.edu.au...
>>
>> I'm a beginner to perl and I tried the following programs:
>>
>> $A = "A\nB";
>> if ( $A == "" ) { print "empty"; };
>>
>> and
>>
>> $A = "A\nB";
>> if ( $A != "" ) { print "not empty"; };
>>
>> and
>>
>> $A = "A\nB";
>> if (! $A == "") { print "not empty"; };
>>
>> The first two didn't produce any output but the third one did. This
>> seems a tad inconsistent to me.
>
>Aside from the obvious mistake of using numerical comparision to compare
>strings I don't quite get the behaviour either.
>I guess it comes down to what is the numerical value of "" (i.e. the empty
>string)?
it's zero .. as is $A
>Either it is 0 (zero), then the first example should fire. Or it is not 0,
>then the second example should fire.
you didn't test this yourself did you ? .. you just believed the
originator .. test it yourself and read the docs
any string that can't be interpreted as a number will be numerically
zero (perldata) .. eg. "56" will be 56 .. but "xyz" will be 0 .. the
null string - "" - is also zero (perldata) .. so the first test will
certainly return true
the only other mystery should be solved by realising that ! binds
tighter than == (perlop) .. so first the NOT "A\nB" is evaluated .. and
stringwise "" and "0" are false and "anything else" is true (perldata)
.. so ! "A\nB" evaluates to false .. which is then compared with 0 and
returns true becase numeric zero equates to false (perldata)
HTH
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Sat, 15 Jul 2000 01:55:54 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: The newbie question
Message-Id: <MPG.13da61f39fd7a3e19896bc@news>
Larry Rosler wrote ..
>In article <MPG.13d977b6fc3224e49896af@news> on Fri, 14 Jul 2000
>09:16:22 GMT, jason <elephant@squirrelgroup.com> says...
>> Andrew Johnson wrote ..
>
>...
>
>> > 1) No, do not attempt a lame reply.
>> >
>> > 2) Yes, do attempt a careful, tested, thought out reply.
>
> 2a) Don't consider any code 'tested' unless it compiles correctly
> and executes without warnings when using the '-w' flag and
> the 'use strict;' pragma.
>
>> > 3) Of course, we all make mistakes -- do not let fear paralyze
>> > you and prevent you from becoming a contributor to the group
>> > (but, see 1 and 2 above :-)
>>
>> 4) preface your answer with a small bit about your level of experience
>> and don't state your answer as fact if you're not 100% certain that
>> it is
>>
>> eg.
>>
>> "
>> I'm working through these comparison tests as well. The following seems
>> to work, not sure if it's correct though because I'm still a beginner.
>>
>> $A = "A\nB";
>> if ( $A = "" ) { print "empty"; }
>> "
>
>My advice 2a above would have saved you from the embarrassment of this
>response. Try it and see.
umm .. just in case you didn't realise .. my response above was an
example of what the originator SHOULD have said when they posted the
code above in the "Silly Question?" thread .. that's why it was prefixed
with 'eg.' and wrapped in quotes and followed my point (4)
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Fri, 14 Jul 2000 19:02:49 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: The newbie question
Message-Id: <396FC649.1FA9FC81@la.znet.com>
Larry Rosler wrote:
> jason wrote:
> > Andrew Johnson wrote ..
(snippage)
> 2a) Don't consider any code 'tested' unless it compiles correctly
> and executes without warnings when using the '-w' flag and
> the 'use strict;' pragma.
If you were to run my creative and imaginative
scripts with pragma hints and strict, your system
would pop so many red flares it would attain critical
mass, blowup in your face rendering you into a grade B
sci-fi movie Toxic Avenger or perhaps a Swamp Thing.
Ironically, my private scripts are so sought after,
a very few have attempted internet crime to obtain
copies of my Perl creativity. Those few learned
hard lessons on how creative are my scripts, thanks
to not using pragma hints and strict.
Pragma hints and strict are both good tools for fresh
beginners, experienced beginners and good tools even
for those with intermediate skills in Perl. However, for
skilled Perl programmers, pragma hints, strict, are both
true nemesises being nothing more than well documented
glitches and bugs, deliberately written into Perl core.
Pragma hints and strict are Perl's equal to Microsoft's
classic Blue Screen of Death.
Don't miscontrue what I say here. I do support use of
pragma hints and strict under appropriate circumstances
and, as you pointed out, circumstances described in previous
articles for this thread, pragma hints would certainly
be beneficial and would have caught some problem coding.
What you can construe is I am saying making blanket
admonitions Perl programmers should always use pragma
hints, always use strict, is very poor advice, actually
advice which does guarantee script failure, at times. At
very best, pragma hints will mislead a progammer into
making script changes which worsen problems or curtail
creativity. Strict will simply crash a script to be ornery.
This is not so true for simple to moderately complex scripts,
types of scripts where pragma hints are beneficial. However,
for truly complex scripts or, in my case, creative scripts,
use of pragma hints, use of strict, is a well guaranteed
Blue Screen of Death.
Pragma hints and strict are good. Pragma hints and strict
are both useful tools. However, use the right tool for the
right job and, always remember to wear eye protection. Never
know when a pragma hint might fly into your eye leading you
to profusely swear like a salty sea seasoned sailor.
*lifts her pirate's style black eye patch*
Know what I mean?
Godzilla!
------------------------------
Date: Fri, 14 Jul 2000 23:13:58 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: The newbie question
Message-Id: <MPG.13d9a0fb5a89d4f498abd1@nntp.hpl.hp.com>
In article <396FC649.1FA9FC81@la.znet.com>, callgirl@la.znet.com says...
...
> Pragma hints and strict are both good tools for fresh
> beginners, experienced beginners and good tools even
> for those with intermediate skills in Perl. However, for
> skilled Perl programmers, pragma hints, strict, are both
> true nemesises being nothing more than well documented
> glitches and bugs, deliberately written into Perl core.
> Pragma hints and strict are Perl's equal to Microsoft's
> classic Blue Screen of Death.
Every programmer *should* set '-w' and 'use strict;' globally. Expert
prorammers may then disable them locally.
Lawyers would describe the use of *should* as 'precatory language',
which should cause little difficulty to one with your grasp of English.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 15 Jul 2000 02:18:39 GMT
From: doglovers@rocketmail.com
Subject: Re: Trying to use an array as a hash value
Message-Id: <396fc8f2.58675416@news.erols.com>
I'm a little weak on references, but my understanding is that you
can't have an array as a hash value, but you can have a reference to
an array as a hash value. So if you create the reference to an array:
$arrayref = \(a,b,c,d), then you put the reference into the the hash:
Message => $arrayref,
which you then dereference with @$arrayref when
you need it. Or you can put in an anonymous array with:
Message => [a,b,c,d]
which would work also. I think.
Irwin
On Fri, 14 Jul 2000 22:10:23 +0000, rhys <rhys.tucker@dtn.ntl.com>
wrote:
>While trying to use Mail::Sendmail I'm having trouble passing an array
>to the Message value of the %mail hash. Ideally what I want to do is
>slurp up a file into an array - @message = <MESSAGE>; and use this
>somehow.
>
>I've been wondering that the solution may be to slurp up the file into a
>scalar variable somehow?.
>
> %mail = ( To => $email_address,
> From => 'me@here.com',
> Message => $message, # problem - want to use an array as
>a # hash value
> Subject => $subject,
> );
------------------------------
Date: Fri, 14 Jul 2000 18:30:11 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: UDP / ICMP checksum generation - 1's complement sum
Message-Id: <MPG.13d95e7e4b9ba0ec98abcf@nntp.hpl.hp.com>
In article <8kobkr$6h6$2@216.155.32.162> on 15 Jul 2000 00:35:39 GMT,
The WebDragon <nospam@nospam.com> says...
> In article <smtdk843nd6139@corp.supernews.com>, "Ingmar"
> <wizard_oz@gmx.net> wrote:
...
> not that it's critical, but you should use #!perl -w to turn compiler
> warnings on, as you would need to set
>
> $sum = 0;
>
> here since below you are adding $_ to the undefined value.
>
> | # ADD ALL WORDs TOGETHER AND AUTOMATICALLY ACCUMULATE THE CARRY OVER BIT
> | for (@data)
> | { $sum = $sum + $_ }
No harm in doing that initialization even if the summation is written
(better) as:
$sum += $_
which wouldn't draw a warning, by special dispensation.
But as an old C programmer, I tend always toward explicit
initialization, because C 'auto' variables are by default initialized
with garbage, not with undef, which politely turns into 0 for the +=
operation.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Jul 2000 06:27:53 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: UDP / ICMP checksum generation - 1's complement sum
Message-Id: <8kp099$74o$1@solti3.sdm.de>
In article <smsnr08qnd6150@corp.supernews.com>, Ingmar Koecher <wizard_oz@gmx.net> wrote:
> I am trying to send out UDP and ICMP packets manually and therefor need to
> calculate the checksum for those packets manually. I am using RawIP perl
> module on LINUX.
> I already looked into the RFC 1071 that explains the generation and the
> algorithm, but I still can't make it work. One problem is that I don't know
> exactly how I calculate a 1's complement sum of hex values. One source I
> have explains it like this:
> 1. Treat the data as a stream of 16-bit words
> 2. Compute the 1's complement sum of the 16-bit words
> 3. Take the 1's complement of the computed sum
> I have a source code in C (at the bottom), but that doesn't help me either
> since I can't program C.
> What I tried:
> I calculated the 1's complement like: $a_compl = ~$a;
> I added all 16-bit words complements
> I added the carry-over bit to the sum
This might be the cause of your troubles - try to omit this step!
Checksums sometimes simply ignore any carry-overs!
> I created the 1's complement of the previously generated sum
Other than that, you're correct, the one's complement means to simply
negate all bits, i.e., $ones_complement = ~$my_data.
But since it says you should use 16 bit values maybe you should also
truncate the extraneous bits (perl uses long integers internally!):
$sum += ~$my_data & 0xFFFF;
Two's complement would be to negate all bits AND to add "1" to the
resulting number; i.e., $twos_complement = ~$my_data + 1.
Good luck!
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Sat, 15 Jul 2000 06:45:02 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Upper-to-lower case problem
Message-Id: <h6ovmssvl0ld33u268b262bbe1114t1ok6@4ax.com>
Jürgen Exner wrote:
>> $batch = $input{'batch'};
>> $batch =~ tr/A-Z/a-z/;
>
>Which of course doesn't work in 95% of the world (hint: you are missing the
>conversion for any extended character).
So what? His input is supposed to be limited to 'a'..'f';
>Use "lc" instead.
Indeed . Much neater. Requires Perl5, though. The only Perl that
matters, nowadays.
p.s. Very often I have to fix broken scripts, so that they run under
5.004. Amazingly how much that has been added in 5.005 -- and in 5.6;
although I don't think I've yet used any new features of that.
--
Bart.
------------------------------
Date: Sat, 15 Jul 2000 01:32:11 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: what mod-perl require
Message-Id: <MPG.13da5c663b18d6f39896b8@news>
richard@sunjapan.com.cn wrote ..
>I am using perl script under Apache. It run well normally. But when I
>move it to mod-perl, it failed. My script is like following:
>
>test1.pl
> sub test(){
> ...do something here
> }
>1;
without you actually stating how this fails or what errors it produces -
we can only go by the code you provided .. and I see the problem ..
you're not using the ... operator correctly in the line above
...do something here
will definitely cause a syntax error
--
jason -- elephant@squirrelgroup.com --
------------------------------
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 3676
**************************************