[29025] in Perl-Users-Digest
Perl-Users Digest, Issue: 269 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 27 16:19:36 2007
Date: Tue, 27 Mar 2007 13:19:26 -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 Tue, 27 Mar 2007 Volume: 11 Number: 269
Today's topics:
Iterating over all elements in a 3D array <n.pontikos@cs.ucl.ac.uk>
Re: Iterating over all elements in a 3D array <n.pontikos@cs.ucl.ac.uk>
Re: Iterating over all elements in a 3D array <simon.chao@fmr.com>
Re: Iterating over all elements in a 3D array <bik.mido@tiscalinet.it>
Re: Iterating over all elements in a 3D array <simon.chao@fmr.com>
Re: Iterating over all elements in a 3D array anno4000@radom.zrz.tu-berlin.de
Re: Iterating over all elements in a 3D array <n.pontikos@xxxxxx.com>
Re: Iterating over all elements in a 3D array <bik.mido@tiscalinet.it>
Re: my $session = new CGI::Session() krakle@visto.com
Re: my $session = new CGI::Session() (Jamie)
new CPAN modules on Tue Mar 27 2007 (Randal Schwartz)
Re: nomenclature <bik.mido@tiscalinet.it>
Re: order of evaluation <sensorflo@gmail.com>
Re: order of evaluation xhoster@gmail.com
Re: order of evaluation <nobull67@gmail.com>
Re: order of evaluation <sensorflo@gmail.com>
Re: order of evaluation <jgibson@mail.arc.nasa.gov>
Re: order of evaluation <mritty@gmail.com>
Re: order of evaluation <someone@example.com>
Re: order of evaluation <nobull67@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 27 Mar 2007 14:47:54 +0100
From: nikolas pontikos <n.pontikos@cs.ucl.ac.uk>
Subject: Iterating over all elements in a 3D array
Message-Id: <eub4fp$ag2q$1@uns-a.ucl.ac.uk>
Is there cleaner way of writing this:
foreach $send (0...$#sr) {
foreach $recv (0...$#{$sr[$send]}) {
foreach $round (0...$#{$sr[$send][$recv]}) { print
"$sr[$send][$recv][$round]:\n";
}
}
}
------------------------------
Date: Tue, 27 Mar 2007 14:55:34 +0100
From: nikolas pontikos <n.pontikos@cs.ucl.ac.uk>
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <eub4u4$ag2q$2@uns-a.ucl.ac.uk>
nikolas pontikos wrote:
> Is there cleaner way of writing this:
>
> foreach $send (0...$#sr) {
> foreach $recv (0...$#{$sr[$send]}) {
> foreach $round (0...$#{$sr[$send][$recv]})
> { print "$sr[$send][$recv][$round]:\n";
> }
> }
> }
Actually sorry what I mean is a more generic way of doing this one which
would work with an N dimensional array.
------------------------------
Date: 27 Mar 2007 06:13:40 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <1175001220.149874.232770@e65g2000hsc.googlegroups.com>
On Mar 27, 9:47 am, nikolas pontikos <n.ponti...@cs.ucl.ac.uk> wrote:
> Is there cleaner way of writing this:
>
> foreach $send (0...$#sr) {
> foreach $recv (0...$#{$sr[$send]}) {
> foreach $round (0...$#{$sr[$send][$recv]}) { print
> "$sr[$send][$recv][$round]:\n";
> }
> }
>
>
>
> }
yes. you needn't use an integer iterator. it's actually more efficient
(and cleaner) to iterate over the array elements themselves.
for my $lev1 ( @sr ) {
for my $lev2 ( @{$lev1} ) {
for my $lev3 ( @{$lev2} ) {
print "$lev3\n";
}
}
}
...you can also probably use maps or something more esoteric if you're
more concerned with brevity and less concerned with readability. also,
i'm not sure if it's more efficient to dereference the arrayref
outside the nested loops or not. if i weren't so lazy i'd benchmark...
------------------------------
Date: Tue, 27 Mar 2007 15:14:28 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <i36i03t7dpadf0b9kgfjcndb2fkoi6mid0@4ax.com>
On Tue, 27 Mar 2007 14:47:54 +0100, nikolas pontikos
<n.pontikos@cs.ucl.ac.uk> wrote:
>Is there cleaner way of writing this:
>
>foreach $send (0...$#sr) {
> foreach $recv (0...$#{$sr[$send]}) {
> foreach $round (0...$#{$sr[$send][$recv]}) { print
>"$sr[$send][$recv][$round]:\n";
> }
> }
>}
local $\=":\n";
for (@sr) {
for(@$_) {
for (@$_) {
print;
}
}
}
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 27 Mar 2007 06:16:04 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <1175001364.632754.26140@n59g2000hsh.googlegroups.com>
On Mar 27, 9:55 am, nikolas pontikos <n.ponti...@cs.ucl.ac.uk> wrote:
> nikolas pontikos wrote:
> > Is there cleaner way of writing this:
>
> > foreach $send (0...$#sr) {
> > foreach $recv (0...$#{$sr[$send]}) {
> > foreach $round (0...$#{$sr[$send][$recv]})
> > { print "$sr[$send][$recv][$round]:\n";
> > }
> > }
> > }
>
> Actually sorry what I mean is a more generic way of doing this one which
> would work with an N dimensional array.
yes. you can write a recursive function, and even imbue it with
intelligence enough to handle nested hashrefs as well as arrayrefs via
the ref function.
------------------------------
Date: 27 Mar 2007 13:43:27 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <56slbvF28dcfsU1@mid.dfncis.de>
nikolas pontikos <n.pontikos@cs.ucl.ac.uk> wrote in comp.lang.perl.misc:
> nikolas pontikos wrote:
> > Is there cleaner way of writing this:
> >
> > foreach $send (0...$#sr) {
> > foreach $recv (0...$#{$sr[$send]}) {
> > foreach $round (0...$#{$sr[$send][$recv]})
> > { print "$sr[$send][$recv][$round]:\n";
> > }
> > }
> > }
>
> Actually sorry what I mean is a more generic way of doing this one which
> would work with an N dimensional array.
Sure.
sub flatten { map ref() ? flatten( @$_) : $_, @_ }
With that you can
print "$_\n" for flatten(
[ 1, 2, 3],
[ 4, 5, 6],
[ 7, 8, 9],
);
The arrays can be arbitrarily nested:
print "$_\n" for flatten(
[ 1, [ 2, 3, 4], [ 4, [ 5, 6], [[[[ 7]]]] ] ], 8, 9,
);
Anno
------------------------------
Date: Tue, 27 Mar 2007 15:40:19 +0100
From: nikolas pontikos <n.pontikos@xxxxxx.com>
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <eub7i2$d410$1@uns-a.ucl.ac.uk>
Michele Dondi wrote:
> On Tue, 27 Mar 2007 14:47:54 +0100, nikolas pontikos
> <n.pontikos@cs.ucl.ac.uk> wrote:
>
>> Is there cleaner way of writing this:
>>
>> foreach $send (0...$#sr) {
>> foreach $recv (0...$#{$sr[$send]}) {
>> foreach $round (0...$#{$sr[$send][$recv]}) { print
>> "$sr[$send][$recv][$round]:\n";
>> }
>> }
>> }
>
> local $\=":\n";
> for (@sr) {
> for(@$_) {
> for (@$_) {
> print;
> }
> }
> }
>
>
> Michele
So $\ is a perl variable that's appended to every string which gets
printed out? That's pretty cool I didn't know that.
Thanks,
--
Nikolas.
------------------------------
Date: Tue, 27 Mar 2007 17:05:59 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Iterating over all elements in a 3D array
Message-Id: <7kci03915ramg7vu6is8oqu8vkjf9b2rc3@4ax.com>
On Tue, 27 Mar 2007 15:40:19 +0100, nikolas pontikos
<n.pontikos@xxxxxx.com> wrote:
>So $\ is a perl variable that's appended to every string which gets
>printed out? That's pretty cool I didn't know that.
I mentioned it beacause I suspected that, and I'm lazily-keen on
argumentless print()s. See
perldoc perlvar
for other builtin variables.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 26 Mar 2007 22:51:19 -0700
From: krakle@visto.com
Subject: Re: my $session = new CGI::Session()
Message-Id: <1174974679.521079.22370@y66g2000hsf.googlegroups.com>
On Mar 24, 11:43 am, Sherm Pendley <spamt...@dot-app.org> wrote:
> "Kevin" <kmhun...@gmail.com> writes:
> > On Mar 22, 3:39 pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
> > wrote:
> >> Kevin wrote:
> >> > When I try to initialize a CGI session with my $session = new
> >> > CGI::Session(), my script hangs and eventually throws a CGI timeout.
> >> > This actually occurs when trying to create a new anything, be it
> >> > session, or CGI, or anything. Any thoughts?
>
> >> What's a "CGI timeout"? The error message it provides, should be a bit
> >> more descriptive.
>
> > The exact error shown in the browser is:
>
> > CGI Timeout
> > The specified CGI application exceeded the allowed time for
> > processing. The server has deleted the process.
>
> How much more descriptive can that be??? Your server has been configured
> with a maximum time allowed for CGI apps. Yours runs for longer than that,
> so the server killed it and returned an error.
>
> sherm--
Duh. That's the obvious. But he wants to know WHAT would cause
CGI::Session to hang up (which caused the execution to exceed the
configured server limit).
------------------------------
Date: Tue, 27 Mar 2007 07:32:59 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: my $session = new CGI::Session()
Message-Id: <Lc1174960368195810x8c8fd84@pong.podro.com>
In <1174744468.622274.180110@y66g2000hsf.googlegroups.com>,
"Kevin" <kmhuntly@gmail.com> mentions:
>On Mar 22, 3:39 pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
>wrote:
>> Kevin wrote:
>> > When I try to initialize a CGI session with my $session = new
>> > CGI::Session(), my script hangs and eventually throws a CGI timeout.
>> > This actually occurs when trying to create a new anything, be it
>> > session, or CGI, or anything. Any thoughts?
>>
>> What's a "CGI timeout"? The error message it provides, should be a bit
>> more descriptive.
>
>The exact error shown in the browser is:
>
>CGI Timeout
>The specified CGI application exceeded the allowed time for
>processing. The server has deleted the process.
>
>HTTP Headers return a 502.
>
>I did some playing with the code, and this only happens when i POST to
>it from a form, if I hardcode the variables sent by the form and go to
>the script directly it works fine..
Going out on a limb, but are you using CGI.pm ?
I'd have a look at whatever-it-is that is reading the standard input, maybe
even use telnet to fake a post with a dummy \n on the end. Perhaps someplace,
in some code far away is a line such as this:
read(STDIN,$buffer,$length);
Try finding that point and working backwards from there. Maybe verify
the $length is indeed the correct length.
It seems like it could be a problem with hanging on the input. (do other post
scripts work? is the web server configured to permit POST?
Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
------------------------------
Date: Tue, 27 Mar 2007 04:42:11 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Mar 27 2007
Message-Id: <JFJp2B.1urE@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Astro-SIMBAD-Client-0.007
http://search.cpan.org/~wyant/Astro-SIMBAD-Client-0.007/
Fetch astronomical data from SIMBAD 4.
----
Bio-Phylo-0.16_RC3
http://search.cpan.org/~rvosa/Bio-Phylo-0.16_RC3/
Phylogenetic analysis using perl.
----
Brick-0.220_01
http://search.cpan.org/~bdfoy/Brick-0.220_01/
Complex business rule data validation
----
Brick-0.221_01
http://search.cpan.org/~bdfoy/Brick-0.221_01/
Complex business rule data validation
----
CGI-Application-Plugin-Apache-1.00
http://search.cpan.org/~wonko/CGI-Application-Plugin-Apache-1.00/
Allow CGI::Application to use Apache::* modules without interference
----
ClearCase-Tools-0.01
http://search.cpan.org/~ccobb/ClearCase-Tools-0.01/
----
Crypt-PBC-0.7.20.0-0.4.9
http://search.cpan.org/~jettero/Crypt-PBC-0.7.20.0-0.4.9/
OO interface for the Stanford PBC library
----
DBIx-Perlish-0.23
http://search.cpan.org/~gruber/DBIx-Perlish-0.23/
a perlish interface to SQL databases
----
DateTime-Format-RSS-0.02
http://search.cpan.org/~dmaki/DateTime-Format-RSS-0.02/
Format DateTime For RSS
----
Egg-Plugin-Cache-0.04
http://search.cpan.org/~lushe/Egg-Plugin-Cache-0.04/
Cache for Egg.
----
Egg-Plugin-Crypt-CBC-0.05
http://search.cpan.org/~lushe/Egg-Plugin-Crypt-CBC-0.05/
The encryption is supported.
----
Egg-Plugin-LWP-0.04
http://search.cpan.org/~lushe/Egg-Plugin-LWP-0.04/
LWP for Egg.
----
Egg-Plugin-MailSend-0.01
http://search.cpan.org/~lushe/Egg-Plugin-MailSend-0.01/
Plugin that offers mail delivery function for Egg.
----
Egg-Plugin-MailSend-0.02
http://search.cpan.org/~lushe/Egg-Plugin-MailSend-0.02/
Plugin that offers mail delivery function for Egg.
----
Egg-Plugin-MailSend-0.03
http://search.cpan.org/~lushe/Egg-Plugin-MailSend-0.03/
Plugin that offers mail delivery function for Egg.
----
ExtUtils-CBuilder-0.18_01
http://search.cpan.org/~kwilliams/ExtUtils-CBuilder-0.18_01/
Compile and link C code for Perl modules
----
ExtUtils-ModuleMaker-0.48
http://search.cpan.org/~jkeenan/ExtUtils-ModuleMaker-0.48/
Better than h2xs for creating modules
----
HTML-ContentExtractor-0.02
http://search.cpan.org/~jzhang/HTML-ContentExtractor-0.02/
extract the main content from a web page by analysising the DOM tree!
----
HTML-FormatText-WithLinks-0.08
http://search.cpan.org/~struan/HTML-FormatText-WithLinks-0.08/
HTML to text conversion with links as footnotes
----
JSON-1.08
http://search.cpan.org/~makamaka/JSON-1.08/
parse and convert to JSON (JavaScript Object Notation).
----
Lemonldap-Portal-Standard-3.1.1
http://search.cpan.org/~egerman/Lemonldap-Portal-Standard-3.1.1/
Perl extension for the Lemonldap SSO system
----
Lucene-0.13
http://search.cpan.org/~tbusch/Lucene-0.13/
API to the C++ port of the Lucene search engine
----
Mac-PropertyList-SAX-0.06
http://search.cpan.org/~kulp/Mac-PropertyList-SAX-0.06/
work with Mac plists at a low level (with real XML parsers)
----
Net-ADNS-0.01
http://search.cpan.org/~salva/Net-ADNS-0.01/
Perl wrapper for the Asynchronous DNS client library
----
Net-Frame-1.04
http://search.cpan.org/~gomor/Net-Frame-1.04/
the base framework for frame crafting
----
Net-Frame-Layer-LLC-1.01
http://search.cpan.org/~gomor/Net-Frame-Layer-LLC-1.01/
Logical-Link Control layer object
----
Net-RawIP-0.21
http://search.cpan.org/~szabgab/Net-RawIP-0.21/
Perl extension for manipulate raw ip packets with interface to libpcap
----
Net-Server-0.96
http://search.cpan.org/~rhandom/Net-Server-0.96/
Extensible, general Perl server engine
----
Net-Telnet-Brcd-0.13
http://search.cpan.org/~lbendavid/Net-Telnet-Brcd-0.13/
Perl libraries to contact Brocade switch
----
Net-YAR-1.065
http://search.cpan.org/~rhandom/Net-YAR-1.065/
Perl interface to the YAR (Yet Another Registrar) API
----
ORM-0.85
http://search.cpan.org/~akimov/ORM-0.85/
Object relational mapper for Perl.
----
Object-InsideOut-3.14
http://search.cpan.org/~jdhedden/Object-InsideOut-3.14/
Comprehensive inside-out object support module
----
POE-Component-PSD-0.02
http://search.cpan.org/~ccobb/POE-Component-PSD-0.02/
----
PTools-Proc-NWay-0.09
http://search.cpan.org/~ccobb/PTools-Proc-NWay-0.09/
Run a list of tasks with concurrent processing
----
PTools-SDF-0.01
http://search.cpan.org/~ccobb/PTools-SDF-0.01/
A collection of Simple Data File utility tools
----
PTools-SDF-DB-0.01
http://search.cpan.org/~ccobb/PTools-SDF-DB-0.01/
----
PTools-SDF-File-Cmd-0.01
http://search.cpan.org/~ccobb/PTools-SDF-File-Cmd-0.01/
----
Params-CallbackRequest-1.16
http://search.cpan.org/~dwheeler/Params-CallbackRequest-1.16/
Functional and object-oriented callback architecture
----
Pod-Tree-1.12
http://search.cpan.org/~swmcd/Pod-Tree-1.12/
Create a static syntax tree for a POD
----
Pushmi-v0.993.0
http://search.cpan.org/~clkao/Pushmi-v0.993.0/
Subversion repository replication tool
----
Pushmi-v0.994.0
http://search.cpan.org/~clkao/Pushmi-v0.994.0/
Subversion repository replication tool
----
Regexp-Common-net-CIDR-0.02
http://search.cpan.org/~ruz/Regexp-Common-net-CIDR-0.02/
provide patterns for CIDR blocks.
----
SVK-v2.0.1
http://search.cpan.org/~clkao/SVK-v2.0.1/
A Distributed Version Control System
----
Socialtext-Wikrad-0.02
http://search.cpan.org/~lukec/Socialtext-Wikrad-0.02/
efficient wiki browsing and editing
----
Template-Process-0.0006
http://search.cpan.org/~ferreira/Template-Process-0.0006/
Process TT2 templates against data files
----
Templates
http://search.cpan.org/~alpo/Templates/
----
Test-Image-0.01
http://search.cpan.org/~fotango/Test-Image-0.01/
test an image
----
Test-MonitorSites-0.12
http://search.cpan.org/~hesco/Test-MonitorSites-0.12/
Monitor availability and function of a list of websites
----
Test-MonitorSites-0.13
http://search.cpan.org/~hesco/Test-MonitorSites-0.13/
Monitor availability and function of a list of websites
----
Test-TAP-Model-0.09
http://search.cpan.org/~nuffin/Test-TAP-Model-0.09/
Accessible (queryable, serializable object) result collector for Test::Harness::Straps runs.
----
Text-vFile-toXML-0.02
http://search.cpan.org/~kulp/Text-vFile-toXML-0.02/
Convert vFiles into equivalent XML
----
WWW-LargeFileFetcher-0.02
http://search.cpan.org/~jzhang/WWW-LargeFileFetcher-0.02/
a module used to fetch large files from internet.
----
WWW-Translate-Apertium-0.01
http://search.cpan.org/~enell/WWW-Translate-Apertium-0.01/
Open source machine translation
----
oEdtk-0.314
http://search.cpan.org/~daunay/oEdtk-0.314/
----
onto-perl-0.30
http://search.cpan.org/~easr/onto-perl-0.30/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
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: Mon, 26 Mar 2007 15:28:44 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: nomenclature
Message-Id: <2fif031dj2tdlbuitifu576s6kf6jq2glk@4ax.com>
On 26 Mar 2007 03:39:45 -0700, "Flo" <sensorflo@gmail.com> wrote:
>I wonder what the commonly used nomenclature in a regex environment
>for the following sentence is. "The regex is applied to the target
>string". I mean especially the verb "being applied" and the noun
>"target string".
I think it is ok.
>A longer sentence which makes it more clear what I mean: If the regex
>'bi*g' applied to the target string 'He is big', 'big' is matched.
Perhaps you mean "if the regex qr/bi*g/ *is* applied to the (target)
string 'He is big', then 'big' matches the regex."
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 26 Mar 2007 07:33:05 -0700
From: "Flo" <sensorflo@gmail.com>
Subject: Re: order of evaluation
Message-Id: <1174919585.312853.44560@p77g2000hsh.googlegroups.com>
Can you also refer me to a rule within the documentation of Perl why
in the first example, where you answered with yes, why it is like
that. I'd like to know the name of the rule which states why the first
and not the second star * greedely matches all. As I said, the fact is
not determined by precedence. Precedence defines other things.
------------------------------
Date: 26 Mar 2007 16:30:08 GMT
From: xhoster@gmail.com
Subject: Re: order of evaluation
Message-Id: <20070326123009.791$g5@newsreader.com>
"Flo" <sensorflo@gmail.com> wrote:
> Can you also refer me to a rule within the documentation of Perl why
> in the first example, where you answered with yes, why it is like
> that.
"Combining pieces together" in perldoc perlre.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 26 Mar 2007 09:35:56 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: order of evaluation
Message-Id: <1174926956.515606.248270@e65g2000hsc.googlegroups.com>
On Mar 26, 3:33 pm, "Flo" <sensor...@gmail.com> wrote without context:
> Can you also refer me to a rule within the documentation of Perl why
> in the first example, where you answered with yes, why it is like
> that. I'd like to know the name of the rule which states why the first
> and not the second star * greedely matches all.
I'm guessing that this is a reply to Paul's post.
You are not quoting enough context for this to make sense. You stated
_yourself_ that the behaviour would be explained by a left-to-right
rule but said you couldn't find such a statement in perlre.
Paul found the phrase "left to right" in perlre.
What are you still having trouble with?
------------------------------
Date: 26 Mar 2007 10:18:19 -0700
From: "Flo" <sensorflo@gmail.com>
Subject: Re: order of evaluation
Message-Id: <1174929499.017426.20840@y80g2000hsf.googlegroups.com>
> Paul found the phrase "left to right" in perlre.
>
> What are you still having trouble with?
Because that phrase is about alternation, i.e. the alternation
operator |. It is thus not applicable to my problem.
Flo
------------------------------
Date: Mon, 26 Mar 2007 10:39:30 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: order of evaluation
Message-Id: <260320071039303767%jgibson@mail.arc.nasa.gov>
In article <1174919585.312853.44560@p77g2000hsh.googlegroups.com>, Flo
<sensorflo@gmail.com> wrote:
> Can you also refer me to a rule within the documentation of Perl why
> in the first example, where you answered with yes, why it is like
> that. I'd like to know the name of the rule which states why the first
> and not the second star * greedely matches all. As I said, the fact is
> not determined by precedence. Precedence defines other things.
The rules for Perl regular expression pattern-matching are described
starting on page 197 in "Programming Perl", 3rd Edition, Wall et. al.
You are referred to Rule 1: "The Engine tries to match as far left in
the string as it can ..." and Rule 6: "The traditional quantifiers
(without a trailing question mark) specify _greedy_ matching ...".
But the Rules are just how the current Perl Regex Engine works, not how
they _must_ work.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: 26 Mar 2007 11:16:30 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: order of evaluation
Message-Id: <1174932990.613228.18850@d57g2000hsg.googlegroups.com>
On Mar 26, 1:18 pm, "Flo" <sensor...@gmail.com> wrote:
> > Paul found the phrase "left to right" in perlre.
>
> > What are you still having trouble with?
>
> Because that phrase is about alternation, i.e. the alternation
> operator |. It is thus not applicable to my problem.
You're right. My mistake. I quoted the wrong passage. Instead, how
about this one, from `perldoc perlretut`?
o Principle 0: Taken as a whole, any regexp will be
matched at the earliest possible position in the string.
o Principle 1: In an alternation "a|b|c...", the leftmost
alternative that allows a match for the whole regexp
will be the one used.
o Principle 2: The maximal matching quantifiers "?", "*",
"+" and "{n,m}" will in general match as much of the
string as possible while still allowing the whole regexp
to match.
o Principle 3: If there are two or more elements in a
regexp, the leftmost greedy quantifier, if any, will
match as much of the string as possible while still
allowing the whole regexp to match. The next leftmost
greedy quantifier, if any, will try to match as much of
the string remaining available to it as possible, while
still allowing the whole regexp to match. And so on,
until all the regexp elements are satisfied.
Pay close attentions to Principles 0 and 3.
Paul Lalli
------------------------------
Date: Mon, 26 Mar 2007 19:18:13 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: order of evaluation
Message-Id: <V%UNh.13682$6z3.8889@edtnps82>
Flo wrote:
> Here the correct link
> http://groups.google.com/group/comp.lang.c/browse_thread/thread/5bc238bd3caaea16/78e3e006c5b99c42?lnk=st&q=math+order+of+evaluation+&rnum=5#78e3e006c5b99c42
While that is a fascinating article on "precedence" and "order of evaluation"
it is talking about the C programming language, it has nothing to do with
regular expressions. For almost everything you need to know about regular
expressions get Jeffrey Friedl's book "Mastering Regular Expressions".
http://www.oreilly.com/catalog/regex3/index.html
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: 27 Mar 2007 09:45:31 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: order of evaluation
Message-Id: <1175013930.997009.300680@p77g2000hsh.googlegroups.com>
On Mar 26, 6:18 pm, "Flo" <sensor...@gmail.com> wrote:
> > Paul found the phrase "left to right" in perlre.
>
> > What are you still having trouble with?
>
> Because that phrase is about alternation, i.e. the alternation
> operator |. It is thus not applicable to my problem.
Opps, my bad.
------------------------------
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 V11 Issue 269
**************************************