[25003] in Perl-Users-Digest
Perl-Users Digest, Issue: 7253 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 14 21:11:54 2004
Date: Thu, 14 Oct 2004 18:10:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 14 Oct 2004 Volume: 10 Number: 7253
Today's topics:
Re: References to an array in a foreach <mail.david@dsl.pipex.com>
Re: References to an array in a foreach <mail.david@dsl.pipex.com>
Re: References to an array in a foreach <usa1@llenroc.ude.invalid>
Re: References to an array in a foreach <usa1@llenroc.ude.invalid>
Re: References to an array in a foreach <dha@panix.com>
Re: setting cookies (mod_perl) <usenet@morrow.me.uk>
Re: Top 10 list algorithm <someone@example.com>
Re: Top posting (was Re: Concatenating an array into on (Hae Jin)
Re: Top posting (was Re: Concatenating an array into on <noreply@gunnar.cc>
Re: Top posting (was Re: Concatenating an array into on <sbryce@scottbryce.com>
Re: Top posting (was Re: Concatenating an array into on <jurgenex@hotmail.com>
Re: Top posting (was Re: Concatenating an array into on <jurgenex@hotmail.com>
Re: Unlink Question (Gary E. Ansok)
Re: Who's responsible for this ? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Oct 2004 23:51:20 +0000
From: David Green <mail.david@dsl.pipex.com>
Subject: Re: References to an array in a foreach
Message-Id: <pan.2004.10.14.23.51.20.244599@dsl.pipex.com>
On Thu, 14 Oct 2004 20:00:03 +0000, A. Sinan Unur spoke:
> David Green <mail.david@dsl.pipex.com> wrote in
> news:pan.2004.10.14.19.59.52.96858@dsl.pipex.com:
>> Take for example the following code:
>>
>> my @animals = ( "\@reptiles", "\@mammals", "\@birds" );
>> my @birds = ( "owl", "swan", "pelican" );
>> my @reptiles = ( "crocodile", "gecko" );
>> my @mammals = ( "fox", "cheeta", "man" );
>>
>> What I think I've done here is set up an array called @animals which
>> contains references to the three arrays @birds, @reptiles and
>> @mammals.
>
> That is absolutely one hundred percent wrong. Where have you every seen
> such syntax? You can't make stuff up and expect it to work you know.
>
It's an adaptation (errors my own) of some code I found online. I hope
that by trialing new ideas I might improve my coding skills. Is that not
how most things, especially new languages are learnt?
> Always declare your variables in the smallest possible scope. Don't give
> them misleading names (such as $key).
Provided as an illustration only, but even so I would question as a
general idea in programming that the problem of having such a named
variable that's going to fall out of scope *very* soon and only iterate
over a set of values is not terribly significant.
>> To even get this code to run I have to remove <use strict> else Perl
>> refuses to run the code.
>
> It is a BAD SIGN when you have to remove use strict to get your code to
> run. Why don't you instead read the message you get?
I did read it (somewhat obviously) and whilst I understood something was
wrong and to some extent why I did not have the knowledge to fix it. Of
course it's a bad sign - why did I run with use strict to start with? It's
an observation that it works without- read my post and you'll see how I
want to run without having to remove it!
>
> You are very clear. You refuse to read.
>
> Have you looked at perldoc perlref?
>
Yes and yes. Notice how others were kind enough to provide a bit of a
description as to where to look. It's fine to tell people to RTFM if you
tell them which manual you would like them to read - I have at least a
thousand pages of documentation packaged with my installation to read, let
alone other resources.
I would be interested in your replies but please some actual content this
time rather than a series of insults and rebuttal that offers no
assistance, such posts are a rather a waste of everyones bandwidth.
David
> Sinan.
--
David Green (mail.david@dsl.pipex.com)
Hands up for human rights!
http://www.amnesty.org
------------------------------
Date: Thu, 14 Oct 2004 23:55:02 +0000
From: David Green <mail.david@dsl.pipex.com>
Subject: Re: References to an array in a foreach
Message-Id: <pan.2004.10.14.23.55.02.799645@dsl.pipex.com>
On Thu, 14 Oct 2004 15:14:30 -0500, Todd de Gruyl rambled:
> ### Here it is with the errors fixed:
>
> use warnings;
> use strict;
>
> my @birds = ( "owl", "swan", "pelican" );
<snip>
Thanks kindly for your help, I'll try this code as well as the
perllol documentation recommended earlier. I think I dropped the
parentheses in a hurry typing - didn't want to copy and paste a lot of
of superfluos code so typed out fresh what I had in mind, appologies.
Regards,
Dave
------------------------------
Date: 14 Oct 2004 23:09:49 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: References to an array in a foreach
Message-Id: <Xns9582C33CFA04Basu1cornelledu@132.236.56.8>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns9582A2C548DB0asu1cornelledu@132.236.56.8:
> David Green <mail.david@dsl.pipex.com> wrote in
> news:pan.2004.10.14.19.59.52.96858@dsl.pipex.com:
>> foreach $thatkey (@animals) {
>>
>> foreach $thiskey (@$thatkey) { # Here I try to dereference the
>> array print $thiskey . ","; # and presumably fail?
>
> I am speechless.
>
> You can't make stuff up like this.
I sincerely apologize for this remark. I do not know where the word 'array'
came from in my copy. Must have been some kind of inadvertent paste on my
part.
To make up for my mistake, here is an answer to your other question:
> The ultimate aim in this seemingly strange setup is to allow an
> unlimited number of members to @animals and an unlimited number of
> animals in each different 'kingdom'. In reality i'm actually using
> such a system to manage a lot of metadata for a package manager I'm
> working on.
What you really want to use is a hash for animals, rather than an array. It
will make your life easier.
That is:
#! perl
use strict;
use warnings;
my %animals = (
birds => [ qw(owl swan pelican) ],
reptiles => [ qw(crocodile gecko) ],
mammals => [ qw(fox cheeta man) ],
);
# add a species to a group
push @{ $animals{birds} }, 'sparrow';
for my $species (keys %animals) {
print ucfirst $species, ": ";
print join(', ', @{ $animals{$species} }), "\n";
}
__END__
Hope this helps.
Sinan.
------------------------------
Date: 14 Oct 2004 23:15:11 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: References to an array in a foreach
Message-Id: <Xns9582C426059C0asu1cornelledu@132.236.56.8>
David Green <mail.david@dsl.pipex.com> wrote in
news:pan.2004.10.14.23.51.20.244599@dsl.pipex.com:
>> You are very clear. You refuse to read.
>>
>> Have you looked at perldoc perlref?
>>
> Yes and yes. Notice how others were kind enough to provide a bit of a
> description as to where to look. It's fine to tell people to RTFM if
> you tell them which manual you would like them to read - I have at
> least a thousand pages of documentation packaged with my installation
> to read, let alone other resources.
I did tell you exactly where to look.
perlref, that is, "Perl references and nested data structures", ought to be
the first place you look at when you are trying to figure out how to take a
reference to something.
Oh, by the way, perldoc perltoc will give you a table of contents so you
don't have to guess.
Sinan.
------------------------------
Date: Fri, 15 Oct 2004 00:31:31 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: References to an array in a foreach
Message-Id: <slrncmu6j3.206.dha@panix2.panix.com>
On 2004-10-14, A. Sinan Unur <usa1@llenroc.ude.invalid> wrote:
>
> What you really want to use is a hash for animals
Really, this sounds like something the SPCA might come after you for...
:-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
And finally, it appears that Schwern, Michael is an Alien Drag Queen
- Leon Brocard, London.pm List Weekly Summary 2001-03-19
(This has *something* to do with http://us.imdb.com/Title?0103645)
------------------------------
Date: Thu, 14 Oct 2004 23:03:18 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: setting cookies (mod_perl)
Message-Id: <6m9342-gi6.ln1@osiris.mauzo.dyndns.org>
Quoth "un" <usenet@root.mailshell.com>:
> I'm trying to learn mod_perl 2
>
> I've created the following script:
> package smmod;
Packages with all-lowercase names are reserved for Perl pragmas. I would
suggest using something else; I would also suggest not using a
top-level namespace but putting it somewhere appropriate ('Writing
modules is easy. Naming modules is hard' [Anno Siegel, c.l.p.m])
Ben
--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* ben@morrow.me.uk *
------------------------------
Date: Thu, 14 Oct 2004 22:41:30 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Top 10 list algorithm
Message-Id: <ugDbd.2929$cr4.2055@edtnps84>
Shawn Corey wrote:
> John W. Krahn wrote:
>
>> Why not use splice? :-)
>>
>> splice @top, $j + 1, 0, $num;
>
> Not enough coffee? Too early in the morning? Failed to read the
> documentation?
Which documentation?
John
--
use Perl;
program
fulfillment
------------------------------
Date: Thu, 14 Oct 2004 16:32:03 -0700
From: "Austin P. So (Hae Jin)" <who@what.where>
Subject: Re: Top posting (was Re: Concatenating an array into one string?)
Message-Id: <ckn2ak$nkr$1@nntp.itservices.ubc.ca>
Michele Dondi wrote:
> I can't really think of any reasonable being thinking of top-posting
> as convenient, but for anyone using (what I consider) a (broken)
> client that quotes the whole message without distingushing marks[*].
When the content of the top-post summarizes or introduces something that
brings the thread or the responses into a more global context, then I
don't see why it is wrong, particularly when a point by point discussion
is not necessary.
But the attitude of the posters here brings up another question:
I really don't understand the fascist notion that things must be done a
certain way in order to belong to the newsgroup community.
In fact, I would have to say it is utterly ironic.
Is it an ego thing? Is it a subconscious impression that people who
top-post inherently are ignoring or dismissing what you write?
What is it?
I'd really like an answer of why you all don't think top-posting is
proper netiquette instead of just "well that's just the way it is...".
Austin
------------------------------
Date: Fri, 15 Oct 2004 02:12:49 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Top posting (was Re: Concatenating an array into one string?)
Message-Id: <2t8j1hF1reg2gU1@uni-berlin.de>
Austin P. So (Hae Jin) wrote:
> I'd really like an answer of why you all don't think top-posting is
> proper netiquette instead of just "well that's just the way it
> is...".
I'm not interested at all in another such explanation, since it has
been explained here a vast number of times, over and over again. The
link in the posting guidelines for this group is one of many web pages
that explains the rational behind it:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
OTOH, even if there claims to be a lot of people with the opposite
"opinion", I for one have not seen one single similar document that
explains the rational why top posting would be the best posting style
in newsgroups and mailing lists. Of course, a lot of people with the
default Outlook settings get defensive when asked to not top post, but
that can't reasonably be considered a founded opinion.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 14 Oct 2004 18:27:15 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Top posting (was Re: Concatenating an array into one string?)
Message-Id: <10mu6avg9eruc36@corp.supernews.com>
Austin P. So (Hae Jin) wrote:
> I really don't understand the fascist notion that things must be done a
> certain way in order to belong to the newsgroup community.
Fascist!?!?!
There are a lot of people here who are very knowledgeable when it comes
to Perl. They don't have to be here. They have other, more productive
things they could be doing with their time. They ask that you respect
their time by using a convention that makes posts easier to read. That
is fascist?
Is waiting in line for your turn fascist? Or any of the other things we
are asked to do to show respect for other's time?
If you don't want to play nice, that's fine. Just don't be surprised
when you find yourself playing alone.
------------------------------
Date: Fri, 15 Oct 2004 00:36:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Top posting (was Re: Concatenating an array into one string?)
Message-Id: <FYEbd.615$mP3.364@trnddc08>
Richard S Beckett wrote:
> When a newbie asks for help, by definition he's a newbie, and doesn't
> know a lot of things that seem obvious to more seasoned hackers. So
Yep, and most people won't have a problem with that. If you are new to Perl
then you probably don't know where to find the documentation, the FAQ, etc.
So you are being pointed to them. Anything wrong with that?
Actually, you are right, there is something wrong with this. If a newbie
would have read the NG for two weeks before posting for the first time, just
as good nettiquette requests, then he would have found the documentation and
the FAQ already. They are really mentioned often enough!
> when the first thing they do is jump down his throat for top posting,
Which of course has nothing to do with being new to Perl but is a violation
of common Usenet ettiquette.
Are you claiming that being new to Perl justifies (or even just excuses) to
ignore or even to deliberately violate nettiquette?
jue
------------------------------
Date: Fri, 15 Oct 2004 00:40:10 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Top posting (was Re: Concatenating an array into one string?)
Message-Id: <K%Ebd.652$mP3.233@trnddc08>
Shawn Corey wrote:
> Scott Bryce wrote:
>> And if someone is responding to different parts of your post, as I am
>> doing here, how do you keep it all in context if it is all top
>> posted?
>
> I call it memory.
You don't know much about Usenet and it's technical workings, are you?
Usenet is an asynchronous medium. "Earlier" posts may very well be
propagated to some servers much later or never or being deleted for one
reason or other.
If _you_ as the poster don't provide proper context chances are people may
not be able to understand what you are talking about because they never had
a chance to learn the context.
jue
------------------------------
Date: Thu, 14 Oct 2004 22:09:44 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: Unlink Question
Message-Id: <ckmtf8$1ir$1@naig.caltech.edu>
In article <Cdzbd.899$9f1.268@trndny05>, Paul Lalli <mritty@gmail.com> wrote:
>> ## DELETE THE .TXT FILES THAT ARE OLDER THAN 1 DAY
>>
>> foreach $FILES (@FILES) {
>> if (-M "$dir/$FILES" > 1) {
>> unlink("$dir/$FILES");
>> }
>> }
>
>I'd think you can combine all this....
>
>unlink ( grep { /.txt/ && -M "$dir/$_" > 1} readdir DIR);
Not quite like that, since unlink() will still see the bare filenames
returned by readdir().
unlink (grep { /\.txt/ && -M > 1} map "$dir/$_", readdir DIR)
but I still prefer unlinking each file individually, since you
can check for errors and give a meaningful message.
-- Gary Ansok
------------------------------
Date: 11 Oct 2004 10:57:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Who's responsible for this ?
Message-Id: <ckdoub$lbo$1@mamenchi.zrz.TU-Berlin.DE>
Eric J. Roode <sdn.girths00869@zoemail.net> wrote in comp.lang.perl.misc:
> Csaba <root@localhost> wrote in news:Xns9574E216AE493rs232@195.129.110.131:
>
> > not exp log srand xor s qq qx xor
> > s x x length uc ord and print chr
> > ord for qw q join use sub tied qx
> > xor eval xor print qq q q xor int
> > eval lc q m cos and print chr ord
> > for qw y abs ne open tied hex exp
> > ref y m xor scalar srand print qq
> > q q xor int eval lc qq y sqrt cos
> > and print chr ord for qw x printf
> > each return local x y or print qq
> > s s and eval q s undef or oct xor
> > time xor ref print chr int ord lc
> > foreach qw y hex alarm chdir kill
> > exec return y s gt sin sort split
> >
> >
>
> It's beautiful, isn't it? No punctuation at all.
...not to mention that it breaks into 14 lines of 33 characters each
with only single blanks a word separators.
> For your enjoyment, I present the exact opposite, a JAPH I wrote a few
> weeks ago. It contains no alphabetic, numeric, or whitespace characters.
> (sadly, it only works on unix-like systems)
>
> --
> Eric
> `$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
> $!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
> $_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
> ;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`
A pretty contrast, the two of them...
Anno
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7253
***************************************