[19249] in Perl-Users-Digest
Perl-Users Digest, Issue: 1444 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 4 21:05:28 2001
Date: Sat, 4 Aug 2001 18:05:07 -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: <996973507-v10-i1444@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 4 Aug 2001 Volume: 10 Number: 1444
Today's topics:
Additional questions <sh@planetquake.com>
Re: Additional questions <Tassilo.Parseval@post.rwth-aachen.de>
Re: Additional questions <krahnj@acm.org>
automatic array elements <citykid@nospam.edu>
Re: automatic array elements <Tassilo.Parseval@post.rwth-aachen.de>
Re: automatic array elements <Tassilo.Parseval@post.rwth-aachen.de>
Re: Baiting Gozilla to obtain quality code for nothing! <Tassilo.Parseval@post.rwth-aachen.de>
Re: Benchmarking Perl modules <Juha.Laiho@iki.fi>
Re: comp.infosystems.www.authoring.cgi now moderated <tsee@gmx.net>
Re: comp.infosystems.www.authoring.cgi now moderated <godzilla@stomp.stomp.tokyo>
Re: comp.infosystems.www.authoring.cgi now moderated <Tassilo.Parseval@post.rwth-aachen.de>
FAQ: What happens if I add or remove keys from a hash w <faq@denver.pm.org>
Re: function prototype, file includes, arrays to functi <Tassilo.Parseval@post.rwth-aachen.de>
Re: function prototype, file includes, arrays to functi <krahnj@acm.org>
Re: How do I make sure I get all form fields and values <goldbb2@earthlink.net>
Re: How do I select a random element from an array? <gm@magpage.com>
Re: Optimum Sum? <godzilla@stomp.stomp.tokyo>
perl versus java <mail@porschberg.de>
Re: perl versus java <Tassilo.Parseval@post.rwth-aachen.de>
Scheduling my PC's shutdown... (Snake Djip)
Re: Setting DOS Variables (Was: Matt Wrights formmail a <Petri_member@newsguy.com>
unusual ploting with GD <citykid@nospam.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 04 Aug 2001 22:16:10 GMT
From: "Sean Hamilton" <sh@planetquake.com>
Subject: Additional questions
Message-Id: <Ku_a7.28121$b_3.2282979@news0.telusplanet.net>
Two additional questions.
1. How does "print" work, in that it allows an argument to be specified, and
if one is not, it defaults to $_? How would myprint be written to do this?
Must I declare two primts, one of which calls the other with $_?
2. Warns: print (...) interpreted as function.
print ('text
another line of text');
What else would it be? Using &print instead eliminates the error, but it
also breaks the script. Do I have to use \n and contain everything to one
line? That gets ugly with HTML.
sh
"Sean Hamilton" <sh@planetquake.com> wrote in message
news:n4_a7.28060$b_3.2278520@news0.telusplanet.net...
> 1. Having a strong background in C and similar, I am somewhat surprised to
> find that you cannot do the following in Perl:
>
> sub myprint ($text)
> {
> print ($text);
> }
>
> myprint ('bleh');
>
> Am I just horribly mistaken, or is there some weird syntax involved, or
> what? Must I use shift? That seems error-prone.
>
> 2. Is this the best way to mimic a server side include?
>
> open (FILE, '<', shift);
> print while read (FILE, $_, 16384);
> close (FILE);
>
> 3. How might I go about passing an array to a function? It seems to just
get
> mashed into the argument list. I tried passing a reference to that array,
> but then couldn't find information on any sort of indirection operator.
>
> sh
>
>
------------------------------
Date: Sun, 05 Aug 2001 00:27:53 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Additional questions
Message-Id: <3B6C76E9.2030307@post.rwth-aachen.de>
Sean Hamilton wrote:
>Two additional questions.
>
>1. How does "print" work, in that it allows an argument to be specified, and
>if one is not, it defaults to $_? How would myprint be written to do this?
>Must I declare two primts, one of which calls the other with $_?
>
Yes, but $_ is not automatically populised when calling a subroutine.
You would explicitely have to set it: $_ = shift;
You can still do 'print shift;' if you want to save a few characters.
>2. Warns: print (...) interpreted as function.
>
Hmmh, I can't reproduce that (at least not as one-liner). Just omit the
brackets, usually you do not need them.
>print ('text
>another line of text')
>
>
>
>What else would it be? Using &print instead eliminates the error, but it
>also breaks the script. Do I have to use \n and contain everything to one
>line? That gets ugly with HTML.
>
If your lines get too long, split them with a comma:
print "long line",
"even longer line",
"etc.";
Or use here-docs for that:
print <<EOF;
long line
even longer line
etc
EOF
It prints everything between <<EOF; and EOF including preserving the
formatting.
Regards,
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sat, 04 Aug 2001 23:58:06 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Additional questions
Message-Id: <3B6C8C6C.8C097AE1@acm.org>
Sean Hamilton wrote:
>
> Two additional questions.
>
> 1. How does "print" work, in that it allows an argument to be specified, and
> if one is not, it defaults to $_?
A lot of Perl's functions use $_ as the default argument. They are all
described in the perlfunc man page. The $_ variable and all of perl's
special variables are in the perlvar man page.
perldoc perlfunc
perldoc perlvar
> How would myprint be written to do this?
> Must I declare two primts, one of which calls the other with $_?
>
> 2. Warns: print (...) interpreted as function.
>
> print ('text
> another line of text');
>
> What else would it be?
A list or an expression.
> Using &print instead eliminates the error, but it
> also breaks the script. Do I have to use \n and contain everything to one
> line? That gets ugly with HTML.
No you don't. Read about the Quote and Quote-like operators in the
perlop man page.
perldoc perlop
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 4 Aug 2001 17:40:05 -0700
From: Les Ander <citykid@nospam.edu>
Subject: automatic array elements
Message-Id: <Pine.LNX.4.33.0108041734560.16822-100000@schewanella.stanford.edu>
Hi,
i would like to build an array automatically.
i know that @arr=(1..10) fills the @arr with elements 1 to 10.
But i want to fill @arr with elements from 10..100 with every 10th
elements. For example in matlab i can say a=[10:10:100]
which will make a=(10, 20, 30, ..,100)
Can i do some thing similar with perl (i.e. can i give an arbitrary
increment to fill up the array?)
I guess i can write a small function to do this but was wondering
if perl has some inbuilt functionality such as this..
thanks
------------------------------
Date: Sun, 05 Aug 2001 02:48:13 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: automatic array elements
Message-Id: <3B6C97CD.8060701@post.rwth-aachen.de>
Les Ander wrote:
>Hi,
>i would like to build an array automatically.
> i know that @arr=(1..10) fills the @arr with elements 1 to 10.
>
>But i want to fill @arr with elements from 10..100 with every 10th
>elements. For example in matlab i can say a=[10:10:100]
>which will make a=(10, 20, 30, ..,100)
>
>Can i do some thing similar with perl (i.e. can i give an arbitrary
>increment to fill up the array?)
>
You could do it thus:
my @array;
$array[$_ * 10] for (1 .. 10);
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sun, 05 Aug 2001 02:53:19 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: automatic array elements
Message-Id: <3B6C98FF.9020406@post.rwth-aachen.de>
Tassilo von Parseval wrote:
> Les Ander wrote:
>
>> Hi,
>> i would like to build an array automatically.
>> i know that @arr=(1..10) fills the @arr with elements 1 to 10.
>>
>> But i want to fill @arr with elements from 10..100 with every 10th
>> elements. For example in matlab i can say a=[10:10:100]
>> which will make a=(10, 20, 30, ..,100)
>>
>> Can i do some thing similar with perl (i.e. can i give an arbitrary
>> increment to fill up the array?)
>>
>
> You could do it thus:
> my @array;
> $array[$_ * 10] for (1 .. 10);
Ah, nonsense of course!
$array[$_] = $_ * 10 for (1 .. 10);
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sun, 05 Aug 2001 02:25:07 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Baiting Gozilla to obtain quality code for nothing!!
Message-Id: <3B6C9263.9080405@post.rwth-aachen.de>
Walnut wrote:
>If you are working on a project and either you, your work mates or the
>boss produce absolutely crap code here is what to do to keep that
>budget under control, meet your deadline and get that pay rise:
>
[snipped a lot of wisdom and sound views]
I couldn't agree with you more! I think your post should be incorporated
into a guide to this newsgroupe, something like "How to be a
comp.lang.perl.miscer". Needless to say that this invaluable guide
should go into the perldocs.
And now, since we all now how to effectively pose questions in this
group, I urge everyone (who hasn't yet) to read the ten golden rules to
answer them that can be found at http://www.5sigma.com/perl/topten.html
. It's a must!
>;)
>
:-)
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: 4 Aug 2001 10:21:11 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Benchmarking Perl modules
Message-Id: <9kgian$t71$1@ichaos.ichaos-int>
"Dave Stafford" <Dave.Stafford@globis.net> said:
>There was a thread recently about performance differences when loading
>libraries such as DBI, CGI etc. I decided to do a little testing myself to
>see if there was really such a difference to the web server overall.
...
Seems interesting; however, I have one question on your test setup:
did you have the browser and server running on the same machine,
and what browser/JVM did you use? As I see it, these play a part, too.
Also, have you thought about making your test harness publicly available?
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sun, 5 Aug 2001 00:51:13 +0200
From: "Steffen Mόller" <tsee@gmx.net>
Subject: Re: comp.infosystems.www.authoring.cgi now moderated
Message-Id: <9khu3m$fu3$04$1@news.t-online.com>
"Godzilla!" <godzilla@stomp.stomp.tokyo> schrieb im Newsbeitrag
news:3B6C4093.5864F5DE@stomp.stomp.tokyo...
> Randal L. Schwartz wrote:
> > If you forge approvals, your posts may be removed unilaterally without
> > notification. This is also a "longstanding Usenet tradition".
>
>
> Otherwords, he will practice discriminatory censorship
> in violation of the cgi group's democratically created
> newsgroup charter. This reminds me of unpleasant events
> which took place here in the now quite distant past.
No!
If you violate the rules by forging approvals, measures to enforce the rules
are democratic.
Democracy has to defend itself, too, at times, don't you think?
Steffen
------------------------------
Date: Sat, 04 Aug 2001 16:24:21 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: comp.infosystems.www.authoring.cgi now moderated
Message-Id: <3B6C8425.4E398D5A@stomp.stomp.tokyo>
Steffen Mόller wrote:
> Godzilla! wrote:
> > Randal L. Schwartz wrote:
> > > If you forge approvals, your posts may be removed unilaterally without
> > > notification. This is also a "longstanding Usenet tradition".
> > Otherwords, he will practice discriminatory censorship
> > in violation of the cgi group's democratically created
> > newsgroup charter. This reminds me of unpleasant events
> > which took place here in the now quite distant past.
> No!
> If you violate the rules by forging approvals, measures to enforce the rules
> are democratic.
> Democracy has to defend itself, too, at times, don't you think?
Only you, under two fake names, and Randal have shouted "forgery!"
Why is this? I have made no mention of forgery.
Ya know, I've thought about this. This cgi newsgroup is not
a moderated newsgroup. Boutell disclaims any authority and,
disclaims any moderation, other than "self-moderation" which
is quite oxymoronic.
For two years I have been posting to the cgi group, posting
hundreds of articles using my Godzilla munged address with
no complaints. Boutell elects to delete the generated email
database and impose a new rule without comment nor warning,
and without a call for vote.
Suddenly, you are accusing me of forging my own munged email
address I have been using for years. So, I forged myself?
For years this has been perfectly fine. Now it is illegal?
I use a little imagination and figure out a hack to enable
posting, make note many others are also hacking and, advising
others how to hack the group so posts will appear. Numerous
people are complaining about not being able to post. Almost
all are helping each other figure out ways to post.
Get this, I've been posting over there for years. Others are
hacking posts to the group. Nonetheless, all of a sudden you
and Randal are wigging out and screaming "FORGERY!" with zero
evidence of such. You even threatened to terminate my account
based on groundless and false accusations. That is criminal.
Where do you two stringless yo-yos get off going around
harassing people with such idiocy?
What you are displaying is a clear case of bigotry and trolling.
So, you gonna go yell at all those other people hacking the cgi
newsgroup so they can post like I have been posting for years?
I am not finished with you. I will further emphasize your true
unsavory intent.
Self-moderation was established in the cgi group to make it
more difficult for spammers to post there. Now, without any
warning, notice nor vote, the rule is, paraphrased, although
Boutell remains silent:
"You must register a valid email address to post here although
this will subject you to email spamming. However, this will
discourage spammers from spamming this group."
Otherwords, no spammers here but if you want to post, you
must agree to be victimized by spammers.
Sensible, yes? About as sensible as this bigotry you, plural,
are openingly displaying.
Forgery my big butt. This is nothing more than the two of you
jumping on a chance to spread hatred, discontent and avail
yourselves a chance to harass someone under false allegations.
Piss poor troll you are, I say.
Godzilla!
------------------------------
Date: Sun, 05 Aug 2001 01:46:34 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: comp.infosystems.www.authoring.cgi now moderated
Message-Id: <3B6C895A.2020902@post.rwth-aachen.de>
Godzilla! wrote:
>Steffen Mόller wrote:
>
>
>>No!
>>If you violate the rules by forging approvals, measures to enforce the rules
>>are democratic.
>>Democracy has to defend itself, too, at times, don't you think?
>>
>
>Only you, under two fake names, and Randal have shouted "forgery!"
>
People being fakes is your favourite allegation, isn't it? You have as
much right to state this as Randal and others have to accuse you of forgery,
>
>
>Why is this? I have made no mention of forgery.
>
Why is this? He has made no mention of fake.
>Ya know, I've thought about this. This cgi newsgroup is not
>a moderated newsgroup. Boutell disclaims any authority and,
>disclaims any moderation, other than "self-moderation" which
>is quite oxymoronic.
>
>For two years I have been posting to the cgi group, posting
>hundreds of articles using my Godzilla munged address with
>no complaints. Boutell elects to delete the generated email
>database and impose a new rule without comment nor warning,
>and without a call for vote.
>
Did it perhaps ever occur to you that these folks are sick of peole like
you? You obviously want democracy. Well, how about making a vote whether
people want you in clpm? 80% of your posts are about complaining about
'parameters' people give in their requests or the imprudency of posting
untested code. I assume your postings to other groups contain of no
fundamentally different things. When you are proud of having taken
participated in a group for over two years, this rather sounds like a
thread than something that should be celebrated.
>Suddenly, you are accusing me of forging my own munged email
>address I have been using for years. So, I forged myself?
>For years this has been perfectly fine. Now it is illegal?
>
>I use a little imagination and figure out a hack to enable
>
You hardly ever use more than 'a little imagination'.
>
>posting, make note many others are also hacking and, advising
>others how to hack the group so posts will appear. Numerous
>people are complaining about not being able to post. Almost
>all are helping each other figure out ways to post.
>
>Get this, I've been posting over there for years. Others are
>hacking posts to the group. Nonetheless, all of a sudden you
>and Randal are wigging out and screaming "FORGERY!" with zero
>evidence of such. You even threatened to terminate my account
>based on groundless and false accusations. That is criminal.
>
Yes, you should immediatly charge them.
>Where do you two stringless yo-yos get off going around
>harassing people with such idiocy?
>
>What you are displaying is a clear case of bigotry and trolling.
>
Again, your favourite word! Can you, by heart, say what a troll is?
[snipped]
>Piss poor troll you are, I say.
>
I think there is nothing else to say. Can someone please switch her off?
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sun, 05 Aug 2001 00:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: What happens if I add or remove keys from a hash while iterating over it?
Message-Id: <1g0b7.34$T3.169981952@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
What happens if I add or remove keys from a hash while iterating over it?
Don't do that. :-)
[lwall] In Perl 4, you were not allowed to modify a hash at all while
iterating over it. In Perl 5 you can delete from it, but you still can't
add to it, because that might cause a doubling of the hash table, in
which half the entries get copied up to the new top half of the table,
at which point you've totally bamboozled the iterator code. Even if the
table doesn't double, there's no telling whether your new entry will be
inserted before or after the current iterator position.
Either treasure up your changes and make them after the iterator
finishes or use keys to fetch all the old keys at once, and iterate over
the list of keys.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.54
--
This space intentionally left blank
------------------------------
Date: Sun, 05 Aug 2001 00:17:00 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: function prototype, file includes, arrays to functions
Message-Id: <3B6C745C.4010903@post.rwth-aachen.de>
Sean Hamilton wrote:
>1. Having a strong background in C and similar, I am somewhat surprised to
>find that you cannot do the following in Perl:
>
>sub myprint ($text)
>{
> print ($text);
>}
>
>myprint ('bleh');
>
sub myprint ($) {
my $arg = shift;
print $arg:
}
Note that you do not need to give a parameter profile in Perl.
>Am I just horribly mistaken, or is there some weird syntax involved, or
>what? Must I use shift? That seems error-prone.
>
>2. Is this the best way to mimic a server side include?
>
I have no idea
>open (FILE, '<', shift);
>print while read (FILE, $_, 16384);
>close (FILE);
>
>3. How might I go about passing an array to a function? It seems to just get
>mashed into the argument list. I tried passing a reference to that array,
>but then couldn't find information on any sort of indirection operator.
>
my @array;
function (\@array);
...
sub function {
my $array_ref = shift;
my @dereferences = @{$array_ref}; # or simply @$array_ref
...
}
You can also do it without reference:
function (@array);
sub function {
my @a = @_;
}
Be careful with other arguments following the array. @a would soak them
all up.
Regards,
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Sat, 04 Aug 2001 23:32:25 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: function prototype, file includes, arrays to functions
Message-Id: <3B6C8667.FD0B18A5@acm.org>
Sean Hamilton wrote:
>
> 1. Having a strong background in C and similar, I am somewhat surprised to
Read the perltrap man page, specifically the section "C Traps".
perldoc perltrap
> find that you cannot do the following in Perl:
>
> sub myprint ($text)
> {
> print ($text);
> }
>
> myprint ('bleh');
>
> Am I just horribly mistaken, or is there some weird syntax involved, or
> what? Must I use shift? That seems error-prone.
The perlsub man page explains all about perl's subroutines.
perldoc perlsub
> 2. Is this the best way to mimic a server side include?
>
> open (FILE, '<', shift);
> print while read (FILE, $_, 16384);
> close (FILE);
>
> 3. How might I go about passing an array to a function? It seems to just get
> mashed into the argument list. I tried passing a reference to that array,
> but then couldn't find information on any sort of indirection operator.
If after reading the documentation you still have questions, feel free
to ask them here. :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 04 Aug 2001 19:59:27 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How do I make sure I get all form fields and values?
Message-Id: <3B6C8C5F.1415B196@earthlink.net>
Walnut wrote:
[snip]
> -------------------------------------------------------------
> Don't reinvent the wheel. Go to http://www.bignosebird.com/cgi.shtml
> to get a script called "bnbform" which will show you how to do this
> and give you more ideas.
> -------------------------------------------------------------
Not only does the referenced script not solve the given problem
[creating a CSV from form data], it is amazingly ugly code -- it does
not use warnings, nor strict, and generally bad coding style.
Only someone very ignorant or stupid would write or use such huge
template-like scripts with small parts that get rewritten for each
purpose it's put to -- normal people use these nifty things called
'modules'.
--
I need more taglines. This one is getting old.
------------------------------
Date: 5 Aug 2001 00:53:36 GMT
From: "~greg" <gm@magpage.com>
Subject: Re: How do I select a random element from an array?
Message-Id: <9ki5eg$mc5$0@216.155.32.133>
John and Bart, thank you.
~
I just read the recent "randomize a hash" thread,
- but not thoroughly.
And it occurred to me that one way to random-sort
an array is like this:
print join (',', sort { int(rand(3))-1 } (1,2,3,4,5,6,7,8,9));
- which works, but it's scary,
because the comparison function isn't consistent.
So I wondered if that could be trusted
to never cause a problem?
~greg
------------------------------
Date: Sat, 04 Aug 2001 15:17:22 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Optimum Sum?
Message-Id: <3B6C7472.C4ADF808@stomp.stomp.tokyo>
benhopkins@mindspring.com wrote:
> Godzilla! wrote:
> > benhopkins@mindspring.com wrote:
(snipped)
> > Oh my, its a rehash of the Knapsnack problem from a
> > few weeks back.
> >> Any suggestions?
> > Yeah, spare us the aggravation and simply post this
> > code you have already written to resolve your
> > Napster Knapsnack problem.
> #!/usr/bin/perl -w
Do I need to test your code to verify it works right?
Isn't this easier? I mean instead of trolling for code,
generating arguments about code, then posting your code
and thumping your chest and all that. Isn't it easier
and more socially graceful to post your code right off
and perhaps add some comments,
"Look at what I wrote! What do you think about my code?"
This is a nice approach and provides more benefit.
Here is a benefit. I have been collecting classic rock
LP vinyl albums for decades. Many are rare, unreleased
or hard-to-find albums. All are in pristine condition
and most have never been opened. I have over a thousand
albums now with all entered into a searchable database
on quite a variety of criteria, including song length
time down to the second.
In time I will transfer these albums to CD, not only by
complete album, but more enjoyable, by song topic. Look:
Topic: Freedom
Animals - Best Of
S1 C1 It's My Life (time)
Byrds - Greatist Hits
S1 C6 Chimes Of Freedom (time)
CSN&Y - So Far
S1 C6 Find The Cost Of Freedom
Bruce Dickenson - Tattooed...
S1 C3 Gypsy Road
Gold & Platinum Volume 4
R2 S4 C4 Fight For Your Right
etc....
White Lion - Big Game
S2 C5 Cry For Freedom
Stevie Winwood - Winwood
R2 S4 C4 Freedom Rider
Woodstock - Soundtrack
S1 C3 Freedom
R2 S4 C4 Freedom Rider (time)
This means: Record 2, Side 4, Cut 4 Title: Freedom Rider 4:52
In our home recording studio, we have a sixteen-hundred watt
stereo system with four tape decks, six high-end turntables,
eight high watt amps, sixteen huge speaker systems, two mixing
boards, microphones, analog-digital converters, my trusty Yahama
keyboard/synthesizer, my old and classic violoncello of course,
most of which is electronically ported to an IBM computer.
Wouldn't it please you to know your code is in use on this system?
So, if I test your code, find it works within acceptable
parameters, I may be tempted to use it to slice out
CD disks based on song topics, arranged for maximum
number of songs per CD. Looks like decent code. Is it?
If so, distribute this code so others can benefit.
However, if you had persisted in your usual bait and
troll tactics, there is not a chance I would use your
code, even if perfect for my needs. This pisses me off.
By being nice, by being upfront, I might benefit from
your code. Chances are, in time, you will find me doing
one-eighty in my Mako Shark, tops down, mine included,
along a moonlit deserted desert highway playing a classic
rock CD at five-hundred watts, getting in the mood for a
getaway in Las Vegas. Be really nice, I might send you
tickets to one of my sleaze bar stand-up comιdie humaine
shows geared towards the bizarre and unmentionable.
I use you as topic at times.
Godzilla!
--
$_="47855853557555
515
0";
tr/
873514/975318642abcdef/;
s/([0-9A-Fa-f]{2})/sprintf("%c",hex($1))/ge;
tr/
/ H-OV-ZP-UA-G/;
print$_=reverse$_;exit;
------------------------------
Date: 05 Aug 2001 00:00:04 +0200
From: Thomas Porschberg <mail@porschberg.de>
Subject: perl versus java
Message-Id: <m3elqr5vvf.fsf@redrat.quark.de>
I search some URL's about the discussion "perl versus java".
I'am espacially interested in differences in runtime behaviour
and the possibility to work with Oracle databases.
------------------------------
Date: Sun, 05 Aug 2001 02:03:05 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: perl versus java
Message-Id: <3B6C8D39.3010104@post.rwth-aachen.de>
Thomas Porschberg wrote:
>I search some URL's about the discussion "perl versus java".
>I'am espacially interested in differences in runtime behaviour
>and the possibility to work with Oracle databases.
>
You may want to look at
http://www.ubka.uni-karlsruhe.de/indexer-vvv/ira/2000/5 . Though, this
is a more global comparison between C, C++, Java, Perl, Python, Rexx and
TCL with no mentioning of database-access. But it is extremely
comprehensive.
You'll see that Perl does in fact perform very well against Java.
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: 4 Aug 2001 18:03:36 -0700
From: snakedjip@yahoo.com (Snake Djip)
Subject: Scheduling my PC's shutdown...
Message-Id: <3318afc0.0108041703.3ae75809@posting.google.com>
Hi there,
I know I can make my PC boot up automatically through a BIOS setting,
but now I'm looking for a way to shut it down, also automatically...
So far, I found this piece of code in Google Groups:
==================
use Win32API::Registry qw( InitiateSystemShutdown AllowPriv );
AllowPriv( "SeShutdownPrivilege", 1 )
or warn "Can't enable local shutdown privilege: $^E\n";
my $reason= "Because I said so";
my( $timeout, $force, $reboot )= ( 60, 0, 0 );
InitiateSystemShutdown( "", $reason, $timeout, $force, $reboot )
or warn "Can't initiate shutdown: $^E\n";
===================
Close, but this has 2 problems :
1- The dialog shown with this code has no "Cancel" button, so that
there's no way to stop the shutdown once it pops up in your face... I
would like to have a dialog saying the same thing, but to also be able
(not programmatically, but through the user interface) cancel the
shutdown...
2- Windows shuts down fine, but the PC remains on, with the "You can
now turn off your PC". It there a way to bypass this message, and
just shut the damn thing off ?
Thanks.
------------------------------
Date: 4 Aug 2001 14:38:44 -0700
From: Petri Oksanen <Petri_member@newsguy.com>
Subject: Re: Setting DOS Variables (Was: Matt Wrights formmail alert)
Message-Id: <9khq1402fop@drn.newsguy.com>
In article <3B6ACC61.E66E40A7@strobedata.com>, Jim says...
> The following snippet is something I used in DOS in 1992.
> This finds the primary command.com. The environment segment
> then has the stuff you can poke around in.
> None of this works under NT, since the 16-bit app gets
> VDMmed and I only fiddle my own virtual space. Maybe this
> will give you something else to waste time with ... er ...
> play with.
Have you tried compiling it as a native Win32 console app?
Then perhaps it won't get stuck in its own VDM.
Or, maybe you could use debug.exe.
That's a big maybe though, accessing memory directly in NT/2K can return some
strange results.
It seems that some things can be read correctly by debug, like the video ROM at
c000:0 and the BIOS ROM (starting at f000:0 on computers I've dealt with, could
be a shadow range), but not hardware info like base addresses for COM- and
LPT-ports at 40:0 onwards.
Everything can be read correctly on Win9x, though.
I once wrote a hack for a fellow sysadmin, which reads the IBM model type and
serial no from system BIOS on his users' computers, using debug.exe.
Luckily, those values appeared at the same addresses on all of his computers,
Thinkpads and desktops alike.
And it works on both Win9x and NT.
If you're interested, here's how I used debug.exe:
---8<---
use strict;
my ($infile, $cnt, $data, $desc, $debug, %sysinfo);
$sysinfo{'Model Type'} = 'd FFFC:8 E';
$sysinfo{'System Serial'} = 'd FFFB:6 C';
#$sysinfo{'IBM System ID'} = 'd FFFB:6 1E';
#$sysinfo{'CPU Type'} = 'd F783:0 15'; # These move around,
#$sysinfo{'CPU Vendor'} = 'd F784:7 1A'; # hopeless.
#$sysinfo{'CPU Name'} = 'd F785:C 17'; # Used WMI instead.
while(($desc, $debug) = each(%sysinfo)) {
$infile = $ENV{'temp'} . '\\' . 'dbg.' . time . '.' . ++$cnt;
open IN, "> $infile" or die "Can't write to '$infile': $!";
print IN "$debug\n";
print IN "q\n";
close IN or die "Can't close '$infile': $!";
$data = `debug <$infile`;
unlink $infile; # Fail silently. Crappy shell on Win32 bugs out.
#unlink $infile or die "Can't remove '$infile': $!";
$data =~ s/^-d.*?\n//; # Erase the d-command line.
$data =~ s/-q.*$//s; # Erase the q-command line.
$data =~ s/^.{61}//mgc; # Erase the offsets and hex dumps.
$data =~ s/\n//s; # Erase all remaining linefeeds.
$data =~ s/^\s+//; # Trim any remaining whitespace at front.
$data =~ s/\s+$//; # Trim at end.
print "$desc:\t$data\n";
}
---8<---
Of course, looking at these specific addresses on a non-IBM PC, will only return
gibberish.
Petri Oksanen
------------------------------
Date: Sat, 4 Aug 2001 15:41:17 -0700
From: Les Ander <citykid@nospam.edu>
Subject: unusual ploting with GD
Message-Id: <Pine.LNX.4.33.0108041518400.15782-100000@schewanella.stanford.edu>
Hi,
I have some data which i would like to plot but i don't know
how to do it. I have used GD::Graph::lines, bar, point etc to draw
regular graphs but the problem i have does'nt seem to file so easily
with them..
This is what i want the plot to look like:
+%%%%%%%%%%+ +%%%%%%%%%%%%%%%%%%%%%%%+
R1 R2
+%%%%%%%%%%+ +%%%%%%%%%%%%%%%%%%%%%%%+
+-----+-----+------+------+------+------+------+
| | | | | | | |
0 100 200 300 400 500 600 700
- +%%%%%%%%%%%+ +%%%%+ +%%%%%%%%%%+
R3 R4 R5
+%%%%%%%%%%%+ +%%%%+ +%%%%%%%%%%+
+-----+-----+------+------+------+------+------+
| | | | | | | |
800 900 1000 1100 1200 1300 1400 1500
+%%%%%%%%%+ +%%%%%%%%%%+ +%%%%%%%%%%%%%+
A1 B4 G2
+%%%%%%%%%+ +%%%%%%%%%%+ +%%%%%%%%%%%%%+
+-----+-----+------+------+------+------+------+
| | | | | | | |
1600 1700 1800 1900 2000 2100 2200 2300
The data that i have looks some thing like this...
50 - 250 R1
325 - 670 R2
940 - 1150 R3
etc..
Does anyone one know how i can do this either with GD or
with some thing else (like postscript ...)
thanks
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 1444
***************************************