[12991] in Perl-Users-Digest
Perl-Users Digest, Issue: 401 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 6 10:17:33 1999
Date: Fri, 6 Aug 1999 07:10:12 -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 Fri, 6 Aug 1999 Volume: 9 Number: 401
Today's topics:
Re: qr{} and quoting pattern metachars <tchrist@mox.perl.com>
Re: qr{} and quoting pattern metachars (Abigail)
Question about hashes ? <codeman@gol.com>
Question about hashes. <codeman@gol.com>
Re: Question about hashes. (Abigail)
Question about hashing. <codeman@gol.com>
Re: split array with \n? <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: split array with \n? <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: split array with \n? (Anno Siegel)
Re: truncation without rounding ejp007@my-deja.com
Re: unpack to a hash? <rick.delaney@home.com>
Re: unpack to a hash? <tchrist@mox.perl.com>
Re: unpack to a hash? (Abigail)
Re: Why is it.... [REPOST] (Anno Siegel)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Aug 1999 06:41:46 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <37aad80a@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
abigail@delanet.com writes:
:This leaves me wondering where the interpolation of "\x20" constructs
:happens.
: $ perl -wle 'print "foo" =~ /o+/ ? "Yes" : "No"'
: Yes
: $ perl -wle 'print "foo" =~ /o\x2b/ ? "Yes" : "No"'
: No
:Note that the POSIX standard says they should be equivalent.
Interesting. You might try bringing this up on p5p, but
I'll pretty much bet it's too change to fix this.
--tom
--
"Some people have told me they don't think a fat penguin really embodies the
grace of Linux, which just tells me they have never seen a angry penguin
charging at them in excess of 100mph. They'd be a lot more careful about
what they say if they had." -- Linus Torvalds
------------------------------
Date: 6 Aug 1999 08:41:57 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: qr{} and quoting pattern metachars
Message-Id: <slrn7qlpfu.8m9.abigail@alexandra.delanet.com>
Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MMCLXVI September
MCMXCIII in <URL:news:7oe5a1$q5p$1@charm.magnus.acs.ohio-state.edu>:
$$
$$ No it is not. It is just that the same pass can do different things
$$ in different situation. Note that some *other* part is not correct:
$$ only some backslash-combinations are passed to REx engine, others are
$$ handled at the level of "Interpolation":
$$
$$ /* leaveit is the set of acceptably-backslashed characters */
$$ char *leaveit =
$$ PL_lex_inpat
$$ ? "\\.^$@AGZdDwWsSbBpPXO+*?|()-nrtfeaxcz0123456789[{]} \t\n\r\f\v#"
$$ : "";
$$
$$ As you could see, \x is passed to REx engine, but \< is processed
$$ right there, during "Interpolation" step.
Ok, this makes sense. Could you add a few lines to the otherwise very
interesting part about the details of parsing quoted constructs that
makes it clear when the backslashed characters are dealt with? Just to
make it complete...
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 6 Aug 1999 21:49:57 +0900
From: "Scott" <codeman@gol.com>
Subject: Question about hashes ?
Message-Id: <7oells$oqf$1@nn-tk001.ocn.ad.jp>
Hi,
Id like to write a perl program to
handle
A list of teachers who on a certain date who recorded certain averages.
would this be an array of arrays or
a list of hashes. Im not sure.
Any advice appreciated.
I need to update the dates in code and add the averages for each
teacher on a certain date.
Scott.
codeman@gol.com
------------------------------
Date: Fri, 6 Aug 1999 21:50:31 +0900
From: "Scott" <codeman@gol.com>
Subject: Question about hashes.
Message-Id: <7oelmu$oql$1@nn-tk001.ocn.ad.jp>
Hi,
Id like to write a perl program to
handle
A list of teachers who on a certain date who recorded certain averages.
would this be an array of arrays or
a list of hashes. Im not sure.
Any advice appreciated.
I need to update the dates in code and add the averages for each
teacher on a certain date.
Scott.
codeman@gol.com
------------------------------
Date: 6 Aug 1999 08:47:08 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Question about hashes.
Message-Id: <slrn7qlppj.8m9.abigail@alexandra.delanet.com>
Scott (codeman@gol.com) wrote on MMCLXVI September MCMXCIII in
<URL:news:7oelmu$oql$1@nn-tk001.ocn.ad.jp>:
$$ Hi,
$$ Id like to write a perl program to
$$ handle
$$
$$ A list of teachers who on a certain date who recorded certain averages.
$$
$$ would this be an array of arrays or
$$ a list of hashes. Im not sure.
This is way to vague to answer it. It all depends what you want to do.
You need to be much, much more specific. Or even better. Just start
writing your code. Often, the appropriate datastructure automagically.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Fri, 6 Aug 1999 21:57:17 +0900
From: "Scott" <codeman@gol.com>
Subject: Question about hashing.
Message-Id: <7oem3j$ose$1@nn-tk001.ocn.ad.jp>
Hi,
Id like to write a perl program to
handle
A list of teachers who on a certain date who recorded certain averages.
would this be an array of arrays or
a list of hashes. Im not sure.
Any advice appreciated.
I need to update the dates in code and add the averages for each
teacher on a certain date.
Scott.
codeman@gol.com
------------------------------
Date: Fri, 06 Aug 1999 08:59:32 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: split array with \n?
Message-Id: <37AADC34.AD0D92E7@ccrs.nrcanDOTgc.ca>
Here's a snippet of the code:
#!/public/bin/perl -w
opendir IDIR, "home/user/" or die "can't open directory: $!";
@pnts= grep !/^\.\.?$/, readdir DIR;
closedir DIR;
foreach $pnt (<@pnts>)
{
do stuff
}
Any ideas?
Thanks
..Tom
Russ Allbery wrote:
>
> Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> writes:
>
> > I am writing a script to execute a program on a list of files, which are
> > stored to an array. Problem is, the process has trouble moving to
> > subsequent files after the first one? How can one split the array so
> > that the process can run on each file? Can one split the array via
> > newline?
>
> I'm sorry, that didn't make any sense at all. Could you possibly post
> some code that demonstrates what you're trying to do and what happens and
> why it's not what you want?
>
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
> 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
--
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: Fri, 06 Aug 1999 09:23:47 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: Re: split array with \n?
Message-Id: <37AAE1E3.FA40A152@ccrs.nrcanDOTgc.ca>
Whoops, typo, should be:
#!/public/bin/perl -w
opendir TDIR, "home/user/" or die "can't open directory: $!";
@pnts= grep !/^\.\.?$/, readdir TDIR;
closedir TDIR;
foreach $pnt (<@pnts>)
{
do stuff
}
Tom Kralidis wrote:
>
> Here's a snippet of the code:
>
> #!/public/bin/perl -w
>
> opendir IDIR, "home/user/" or die "can't open directory: $!";
> @pnts= grep !/^\.\.?$/, readdir DIR;
> closedir DIR;
>
> foreach $pnt (<@pnts>)
> {
> do stuff
> }
>
> Any ideas?
>
> Thanks
>
> ..Tom
>
> Russ Allbery wrote:
> >
> > Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> writes:
> >
> > > I am writing a script to execute a program on a list of files, which are
> > > stored to an array. Problem is, the process has trouble moving to
> > > subsequent files after the first one? How can one split the array so
> > > that the process can run on each file? Can one split the array via
> > > newline?
> >
> > I'm sorry, that didn't make any sense at all. Could you possibly post
> > some code that demonstrates what you're trying to do and what happens and
> > why it's not what you want?
> >
> > --
> > #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> > $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
> > 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> > rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
>
> --
>
> -----------------------------------------------------------------------------------------
> Tom Kralidis Geo-Spatial Technologist
> Canada Centre for Remote Sensing Tel: (613) 947-1828
> 588 Booth Street , Room 241 Fax: (613) 947-1408
> Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
> -----------------------------------------------------------------------------------------
--
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
588 Booth Street , Room 241 Fax: (613) 947-1408
Ottawa , Ontario K1A 0Y7 http://www.ccrs.nrcan.gc.ca
-----------------------------------------------------------------------------------------
------------------------------
Date: 6 Aug 1999 13:37:04 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: split array with \n?
Message-Id: <7oeoe0$g53$1@lublin.zrz.tu-berlin.de>
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote in comp.lang.perl.misc:
>Whoops, typo, should be:
>
>#!/public/bin/perl -w
>
> opendir TDIR, "home/user/" or die "can't open directory: $!";
> @pnts= grep !/^\.\.?$/, readdir TDIR;
> closedir TDIR;
>
> foreach $pnt (<@pnts>)
Whatever the typo you corrected, the line above is probably not
what you want. It is interpreted as a file glob in the current
directory and could give you spurious filenames.
Anno
------------------------------
Date: Fri, 06 Aug 1999 13:01:40 GMT
From: ejp007@my-deja.com
Subject: Re: truncation without rounding
Message-Id: <7oembd$4bp$1@nnrp1.deja.com>
In article <37a9b8ac.115625957@news.hydro.co.uk>,
gary@onegoodidea.com (Gary O'Keefe) wrote:
> ericp@us.ibm.com wrote:
>
> >I'm writing a CGI script for calculating a golfers handicap. The
number
> >produced has to be truncated to the tenths without rounding. I know
> >that both printf() and sprintf() will round the last digit, so how do
I
> >make it NOT round?
>
> #!/usr/local/bin/perl -w
>
> use strict;
>
> my $handicap = 15.57;
> printf ( "%.1f\n", int ( $handicap * 10 ) / 10 );
>
> which you would have found if you'd looked up the perlfunc
> documentation.
Sorry to bother you. But thanks for telling me anyway!
>
> Look at the watch. Watch it swing. You are feeling sleepy. Sleepy.
> Sleeeepppyyyy.... You will look at the documentation for perl. You
> will do this before posting to comp.lang.perl.misc. You will enjoy
> looking at the documentation. The documentation will give you the
> answers you need. If you ask a question on comp.lang.perl.misc and
> it's answer is in the FAQs you will feel ashamed of yourself. When I
> snap my fingers you will awaken, feeling refreshed and with an
> overwhelming desire to look at the documentation that came with perl.
>
> *SNAP*
I will obey, I will obey... but when I can't find it I will come back
here... and bother you some more. hehehe
>
> Hope this helps
>
> Gary
> --
> Gary O'Keefe
> gary@onegoodidea.com
>
> You know the score - my current employer has nothing to do with what I
post
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 06 Aug 1999 12:09:34 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: unpack to a hash?
Message-Id: <37AAD05B.E0D8FF89@home.com>
[posted & mailed]
jwilde74@my-deja.com wrote:
>
>
> ($H{trc}, $H{st1}, $H{st2}, $H{st3}, $H{st4}, $H{st5}) =>
^^
=
> unpack("a2 x4 a2 a2 a2 a2 a2" , $buffer);
Use a hash slice.
@H{ qw/trc st1 st2 st3 st4 st5/ } =
unpack("a2 x4 a2 a2 a2 a2 a2 " , $buffer);
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: 6 Aug 1999 07:22:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: unpack to a hash?
Message-Id: <37aae183@cs.colorado.edu>
[courtesy cc of this posting mailed to cited authors]
In comp.lang.perl.misc, : Alex Farber <alex@kawo2.rwth-aachen.de>
responds to jwilde74@my-deja.com:
:So you are actually trying
:
: ($H{trc}, $H{st1}, $H{st2}, $H{st3}, $H{st4}, $H{st5}),
: unpack("a2 x4 a2 a2 a2 a2 a2" , $buffer);
Combining rendundant portions and a bit of creative use
of whitespace and parallelism can do a lot for legibility:
@H{ qw/trc st1 st2 st3 st4 st5/ } =
unpack q/a2 x4 a2 a2 a2 a2 a2 /, $buffer;
--tom
--
------------------------------
Date: 6 Aug 1999 08:55:19 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: unpack to a hash?
Message-Id: <slrn7qlq90.8m9.abigail@alexandra.delanet.com>
jwilde74@my-deja.com (jwilde74@my-deja.com) wrote on MMCLXVI September
MCMXCIII in <URL:news:7oe6rr$qao$1@nnrp1.deja.com>:
"" To populate %H, I currently use substr to pull
"" $buffer apart.
""
"" %H = (
"" trc => substr($buffer, 0, 2),
"" st1 => substr($buffer, 6, 2),
"" st2 => substr($buffer, 8, 2),
"" st3 => substr($buffer, 10, 2),
"" st4 => substr($buffer, 12, 2),
"" st5 => substr($buffer, 14, 2),
"" );
""
"" I imagine that using unpack() rather than substr()
"" would be a more efficient way to do this.
"" However, nothing I've tried seems to work. Here's
"" my latest attempt.
""
""
"" ($H{trc}, $H{st1}, $H{st2}, $H{st3}, $H{st4},
"" $H{st5}) =>
"" unpack("a2 x4 a2 a2 a2 a2 a2" , $buffer);
""
Try using = instead of =>. Didn't -w complain?
Other approaches:
@H {qw /trc st1 st2 st3 st4 st5/} =
$buffer =~ /^(..)....(..)(..)(..)(..)(..)/s;
@H {qw /trc st1 st2 st3 st4 st5/} =
(grep {length} split $buffer => /(..)/s) [0, 3 .. 7];
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 6 Aug 1999 12:33:10 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why is it.... [REPOST]
Message-Id: <7oekm6$fv0$1@lublin.zrz.tu-berlin.de>
Abigail <abigail@delanet.com> wrote in comp.lang.perl.misc:
>Tom Christiansen (tchrist@mox.perl.com) wrote on MMCLXV September
>MCMXCIII in <URL:news:37a9f8af@cs.colorado.edu>:
>Sure. Everyone has an idea what talent is, although many will be hard
>pressed if asked to define it properly. But talent isn't a requirement
>to become a programmer.
>
>[] Some people have a knack for programming, but most people don't.
>
>Yep. So, most people just have to work harder than the lucky few.
>
>[] Talent cannot be instilled.
>[] Talent cannot be learned.
>[] Talent cannot be taught.
>[] Talent cannot be bought.
>[] Talent cannot be created.
>
>True. Talent isn't required though.
Well... I think it is. At least one trait most "talented" people have
is required. Let me explain.
At another point in this thread, Abigail said (and I hope I don't misquote
too rudely) "If you you lack talent you'll have to make do with hard
work". Well, I don't think there is that much make-do. The popular
Edison quote about genius being 1% inspiration and 99% perspiration is
often misunderstood. He doesn't say that only one percent of what a
genius does is really genial, but genius *is* ninety-nine percent work.
What he doesn't say is what makes the genial, or less pretentiously,
talented, person work so hard.
My answer to that is, it's interest. Not the passing sensation people
feel when they say, Oh, that's interesting, but the enduring passion
that drives people to become a mean rock guitarist, write beautiful
programs or perfect the most complete stamp collection they can afford.
Thomas Mann has one of his figures flippantly define interest as love
with the animal warmth removed. This is the kind of interest which,
if it's supported by the requisite perseverance, makes talent. A
good IQ may help, but it's not all that important. Also, if you get
to measure the IQ of people with this kind of dedication, you'll
probably find a high one. No surprise there.
Talent isn't, for the most part, a gift that makes hard things easy.
It's a gift that makes people learn to do hard things as if they
were easy. But man, have they worked for it. Examples abound.
Pablo Casals, the celebrated Spanish cellist and composer, has been
said to have practiced eight hours a day, every day, from late
childhood till in his nineties. No wonder he could play a near-
perfect rendition of any piece of music you cared to throw at him
(and he cared to play). Did it come easy?
I guess what I want to say is, talent isn't that much of a mystery
it is made out to be. It's a rare combination of focussed interest
and endurance which, to a lesser degree, is found in us mere mortals
also. And so, yes, talent is required to do any job well, included
programming.
Anno
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 401
*************************************