[24952] in Perl-Users-Digest
Perl-Users Digest, Issue: 7202 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 2 21:08:07 2004
Date: Sat, 2 Oct 2004 18:05:09 -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 Sat, 2 Oct 2004 Volume: 10 Number: 7202
Today's topics:
CfP: German Perl Workshop 2005 <schwigon@webit.de>
Custom Perl Scripting <lsmsintelligence@hotmail.com>
Re: Custom Perl Scripting <vilain@spamcop.net>
Re: Custom Perl Scripting <noreply@gunnar.cc>
How to test if I got Mod_Perl in apache? <asdf@asdfsadf.com>
Re: Is PHP still slower than Perl? <tony@NOSPAM.demon.co.uk>
Re: Is PHP still slower than Perl? <asdf@asdfsadf.com>
Re: Is PHP still slower than Perl? <dmcbride@naboo.to.org.no.spam.for.me>
Re: Is PHP still slower than Perl? <tassilo.von.parseval@rwth-aachen.de>
Re: Is PHP still slower than Perl? <news_comp.lang.perl.misc@canopus.nl>
Re: Is PHP still slower than Perl? <postmaster@castleamber.com>
Re: Is PHP still slower than Perl? <asdf@asdfsadf.com>
Re: making easy things difficult: @a-@b <ebohlman@omsdev.com>
Regexp::Common OO interface <usa1@llenroc.ude.invalid>
Re: Regexp::Common OO interface <jkeen_via_google@yahoo.com>
Re: Regexp::Common OO interface <usa1@llenroc.ude.invalid>
Re: Regexp::Common OO interface <abigail@abigail.nl>
Re: Regexp::Common OO interface <usa1@llenroc.ude.invalid>
Re: removing empty split() fields (dutone)
Re: Syntax appears inconsistent - why is this? <pinyaj@rpi.edu>
Re: Syntax appears inconsistent - why is this? <abigail@abigail.nl>
Re: While query <abigail@abigail.nl>
Re: While query <abigail@abigail.nl>
Re: While query <usa1@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 02 Oct 2004 22:07:04 +0200
From: Steffen Schwigon <schwigon@webit.de>
Subject: CfP: German Perl Workshop 2005
Message-Id: <87r7oghok7.fsf@lamebrain.teufelkommraus.webit.de>
7. German Perl-Workshop -- Call for Papers / Participation
Datum/Date: 09.02.2005 - 11.02.2005
Ort/Location: Dresden
The 7th German Perl-Workshop will take place from 09.02.2005 to 11.02.2005
in Dresden, Germany. As always we welcome talk or tutorial proposals from
international participants. See www.perl-workshop.de/2005/docs/cfp.htm for
a detailed Call for Papers.
--
Steffen Schwigon <schwigon@webit.de>
Dresden Perl Mongers <http://dresden-pm.org/>
------------------------------
Date: 2 Oct 2004 11:58:13 -0700
From: "Perl Newbie" <lsmsintelligence@hotmail.com>
Subject: Custom Perl Scripting
Message-Id: <1096743493.454729.47530@h37g2000oda.googlegroups.com>
I am trying to set up a webpage that uses four frames in a frameset:
the top frame (most important links), the left-hand frame (other
links), the center frame (bloxom post material), and the right-hand
frame (links specifict to which part of my site you are in). I am
trying to figure out if and how I can write a Perl script that would
tell the browser which page to display in the right-hand frame based
on the page being displayed in the center frame. Can someone help me
on this one?
------------------------------
Date: Sat, 02 Oct 2004 13:06:50 -0700
From: "Michael Vilain <vilain@spamcop.net>"
Subject: Re: Custom Perl Scripting
Message-Id: <vilain-25BC11.13065002102004@comcast.dca.giganews.com>
In article <1096743493.454729.47530@h37g2000oda.googlegroups.com>,
"Perl Newbie" <lsmsintelligence@hotmail.com> wrote:
> I am trying to set up a webpage that uses four frames in a frameset:
> the top frame (most important links), the left-hand frame (other
> links), the center frame (bloxom post material), and the right-hand
> frame (links specifict to which part of my site you are in). I am
> trying to figure out if and how I can write a Perl script that would
> tell the browser which page to display in the right-hand frame based
> on the page being displayed in the center frame. Can someone help me
> on this one?
If I understand your problem, you're describing something that's going
on _in your browser_, not on the server where Perl runs. So, it seems
that unless you control the complete display of all the frames and their
state for each session connected to the server, I don't see a way for
you to do this. I also don't think a web server is really setup this
way--to just be a display device.
I think you need to use Javascript, which runs on the browser and knows
all about what's going on in it. I don't think Javascript can initiate
a request back to the server on it's own, however. For that you need a
program actually running on the client, like a Java applet.
This is really ugly just to get what you want, but I can't think of
another way to do it. You might try posing this question in javascript
and java groups.
--
DeeDee, don't press that button! DeeDee! NO! Dee...
------------------------------
Date: Sat, 02 Oct 2004 23:20:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Custom Perl Scripting
Message-Id: <2s8khqF1hpnnrU1@uni-berlin.de>
Perl Newbie wrote:
> I am trying to set up a webpage that uses four frames in a
> frameset: the top frame (most important links), the left-hand frame
> (other links), the center frame (bloxom post material), and the
> right-hand frame (links specifict to which part of my site you are
> in). I am trying to figure out if and how I can write a Perl
> script that would tell the browser which page to display in the
> right-hand frame based on the page being displayed in the center
> frame.
If the frameset document is generated by a CGI script written in Perl,
you can apply whichever rules you like for composing it.
What's the problem?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 2 Oct 2004 20:42:39 -0400
From: "@" <asdf@asdfsadf.com>
Subject: How to test if I got Mod_Perl in apache?
Message-Id: <BoWdnYZygPCG1sLcRVn-jA@rogers.com>
Is there any way to tell if mod_perl is installed in apache? I am using a
shared account. No root access.
------------------------------
Date: Sat, 2 Oct 2004 19:13:58 +0100
From: "Tony Marston" <tony@NOSPAM.demon.co.uk>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <cjmr56$kjq$1$8300dec7@news.demon.co.uk>
"John Bokma" <postmaster@castleamber.com> wrote in message
news:Xns957679BFC204Bcastleamber@130.133.1.4...
> "@" <asdf@asdfsadf.com> wrote in news:hOSdnRvNILPWwsPcRVn-jw@rogers.com:
>
>> A benchmark in 2002 showed PHP is much slower in shell or when Apache
>> has Mod_Perl.
>>
>> With the new PHP kissing Java's ass, Perl is once again the #1 CGI
>> choice.
>
> For me Perl is #1 (if possible) because PHP is probably the worst designed
> language ever. I am not sure if you can already prepare statements
> (MySQL),
Yes you CAN use prepare statemetnts with MySQL. You should be aware that
this is a MySQL feature, not a PHP feature.
> something I used in Perl ages ago, or still have to use all those
> whatsamacalled_quote_shebang garbage.
If you don't like PHP then why are you posting to the PHP newsgroup?
--
Tony Marston
http://www.tonymarston.net
------------------------------
Date: Sat, 2 Oct 2004 15:52:32 -0400
From: "@" <asdf@asdfsadf.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <HaadndeeKdyAmsLcRVn-hA@rogers.com>
> > A benchmark in 2002 showed PHP is much slower in shell or when Apache
has
> > Mod_Perl.
> >
> > With the new PHP kissing Java's ass, Perl is once again the #1 CGI
choice.
>
> If you want to troll, please put a little more effort in it.
>
> Like make up some benchmarks to support your facts.
>
> --
>
> Daniel Tryba
>
google with PHP PERL BENCHMARK, you will see the results. That is the one
back from 2002.
http://216.239.39.104/search?q=cache:xn2anlI7-dQJ:forums.invisionpower.com/lofiversion/index.php/t24774.html+php+perl+benchmark+2002&hl=en
------------------------------
Date: Sat, 02 Oct 2004 20:50:55 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <PwE7d.570374$M95.475024@pd7tw1no>
Janwillem Borleffs wrote:
> @ wrote:
>> With the new PHP kissing Java's ass, Perl is once again the #1 CGI
>> choice.
>>
>
> You mean this regarding PHP 5's OO model? You have never looked at Perl
> 6's OO model, haven't you?
First off, as Perl 6 doesn't really exist yet, the original flame^Wpost
must be comparing against Perl 5.
Second, Perl 6's OO model could yet do a few 180's.
Third, who said anyone would use Perl 6 for CGI?
Fourth, who said Perl 6's performance would suck?
Fifth, I'm not saying PHP 5's performance sucks - I'm just inferring it
from @'s flame^Wpost.
------------------------------
Date: Sat, 2 Oct 2004 23:06:21 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <2s8jmcF1ib990U1@uni-berlin.de>
Also sprach Joe Smith:
> @ wrote:
>
>> C. I don't know why it is not popular.
>
> I'd say it is because C does not have strings as a native data type.
> Other than initializing an array of char, the C compiler has no
> string manipulation built in; it requires library functions to do that.
That's a distinction in C that's moot. It has no built-in IO mechanisms
either. You have to include a header to get this functionality. But
nonestheless, it's still part of the language.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 2 Oct 2004 23:46:13 +0000 (UTC)
From: Daniel Tryba <news_comp.lang.perl.misc@canopus.nl>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <cjnek5$nu$1@news.tue.nl>
In comp.lang.php @ <asdf@asdfsadf.com> wrote:
>>
>> If you want to troll, please put a little more effort in it.
>>
>> Like make up some benchmarks to support your facts.
>
> google with PHP PERL BENCHMARK, you will see the results.
That is not how it works: you make a claim, so you supply your proof. And
I'm more interested in perl/php vs. java.
> That is the one
> back from 2002.
2002 is so 2 years ago, that like ancient man.
--
Daniel Tryba
------------------------------
Date: 3 Oct 2004 00:27:50 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <Xns9576C5FB187DCcastleamber@130.133.1.4>
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in
news:cjmr56$kjq$1$8300dec7@news.demon.co.uk:
>
> "John Bokma" <postmaster@castleamber.com> wrote in message
> news:Xns957679BFC204Bcastleamber@130.133.1.4...
>> "@" <asdf@asdfsadf.com> wrote in
>> news:hOSdnRvNILPWwsPcRVn-jw@rogers.com:
>>
>>> A benchmark in 2002 showed PHP is much slower in shell or when
>>> Apache has Mod_Perl.
>>>
>>> With the new PHP kissing Java's ass, Perl is once again the #1 CGI
>>> choice.
>>
>> For me Perl is #1 (if possible) because PHP is probably the worst
>> designed language ever. I am not sure if you can already prepare
>> statements (MySQL),
>
> Yes you CAN use prepare statemetnts with MySQL.
> You should be aware
> that this is a MySQL feature, not a PHP feature.
How can I use it from PHP?
>> something I used in Perl ages ago, or still have to use all those
>> whatsamacalled_quote_shebang garbage.
>
> If you don't like PHP then why are you posting to the PHP newsgroup?
Look at the headers, this has been crossed to a Perl group. Besides, I
hope the PHP group isn't only there for people who say it's a great
language? (which it isn't).
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sat, 2 Oct 2004 20:39:36 -0400
From: "@" <asdf@asdfsadf.com>
Subject: Re: Is PHP still slower than Perl?
Message-Id: <BoWdnYdygPCH1sLcRVn-jA@rogers.com>
> >>
> >> If you want to troll, please put a little more effort in it.
> >>
> >> Like make up some benchmarks to support your facts.
> >
> > google with PHP PERL BENCHMARK, you will see the results.
>
> That is not how it works: you make a claim, so you supply your proof. And
> I'm more interested in perl/php vs. java.
>
> > That is the one
> > back from 2002.
>
> 2002 is so 2 years ago, that like ancient man.
>
I personally did my own benchmark in late 2003. I am not an expert at
benchmarking softwares, but it is true Perl is much faster than PHP from my
result. I used PHP/Perl in web enviroment for printing one line per hit.
------------------------------
Date: 2 Oct 2004 18:17:26 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: making easy things difficult: @a-@b
Message-Id: <Xns9576881BD919Aebohlmanomsdevcom@130.133.1.4>
ioneabu@yahoo.com (wana) wrote in
news:bf0b47ca.0410020653.22500027@posting.google.com:
>> // I finally settled for the old C way of doing it of having a loop
>> in a // loop to compare each value of one array against each value
>> of the // other.
>>
>> That's very inefficient. If both arrays contain 1000 elements, you
>> would be doing 1_000_000 comparisons.
>>
> Not if you break out of the inner loop when you find a match. This
> will cut back considerably on the number of comparisons.
It won't change the time complexity, though. The run time will still be
roughly proportional to N*M, whereas with the hash solution it will be
roughly proportional to N+M.
Breaking out of the inner loop on a match will cut the run time in half, on
average. But N*M/2 is still greater than N+M for N and M greater than 4.
>> The solutions from the faq are (nearly) linear.
>>
>
> Yes, after you have the hash created. How long does it take to index
> a newly created hash so you can look up those keys so quickly?
Creating a hash is pretty close to linear, so you're still talking N+M.
------------------------------
Date: 2 Oct 2004 18:56:38 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Regexp::Common OO interface
Message-Id: <Xns9576982A03C35asu1cornelledu@132.236.56.8>
Hello All:
I am a little confused and would appreciate another set of eyes looking at
the following script and telling me what I am not getting:
#! perl
use strict;
use warnings;
use Regexp::Common qw(number RE_num_real);
my %validators = (
operator => sub {
my $v = shift;
if( $v =~ /^$RE{num}{real}{-keep}{-places => '0,2'}$/ ) {
print "matched!\n";
return $1;
}
return;
},
object_oriented => sub {
my $v = shift;
if( $RE{num}{real}{-keep}{-places => '0,2'}->matches($v) ) {
print "matched!\n";
return $1;
}
return;
},
subroutine_interface => sub {
my $v = shift;
if( $v =~ RE_num_real(-keep => 1, -places => '0,2') ) {
print "matched!\n";
return $1;
}
return;
},
);
my @values = qw(1 1.1 1.11 1.111);
for my $v (keys %validators) {
print "Using [ $v ]:\n";
for my $value (@values) {
if(defined (my $validated = $validators{$v}->($value))) {
print "$value\t: validated\n";
} else {
print "$value\t: not validated\n";
}
}
print "---\n";
}
__END__
This script produces the following output:
D:\Home\htdocs\test.cgi> perl tv.pl
Using [ operator ]:
matched!
1 : validated
matched!
1.1 : validated
matched!
1.11 : validated
1.111 : not validated
---
Using [ object_oriented ]:
matched!
1 : not validated
1.1 : not validated
1.11 : not validated
1.111 : not validated
---
Using [ subroutine_interface ]:
matched!
1 : validated
matched!
1.1 : validated
matched!
1.11 : validated
matched!
1.111 : validated
---
I would have expected the output to be identical in using all three
methods. I can't figure out why. Any ideas?
Thanks.
Sinan.
------------------------------
Date: Sat, 02 Oct 2004 22:45:35 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: Regexp::Common OO interface
Message-Id: <jcG7d.983$6y6.412@trndny02>
A. Sinan Unur wrote:
>
> This script produces the following output:
>
> D:\Home\htdocs\test.cgi> perl tv.pl
> Using [ operator ]:
> matched!
> 1 : validated
> matched!
> 1.1 : validated
> matched!
> 1.11 : validated
> 1.111 : not validated
> ---
> Using [ object_oriented ]:
> matched!
> 1 : not validated
> 1.1 : not validated
> 1.11 : not validated
> 1.111 : not validated
> ---
> Using [ subroutine_interface ]:
> matched!
> 1 : validated
> matched!
> 1.1 : validated
> matched!
> 1.11 : validated
> matched!
> 1.111 : validated
> ---
>
> I would have expected the output to be identical in using all three
> methods. I can't figure out why. Any ideas?
>
I confirm your results and your perplexity. Am I correct in thinking
that the results you expected were those from the 'operator' interface?
Jim Keenan
------------------------------
Date: 2 Oct 2004 22:56:00 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Regexp::Common OO interface
Message-Id: <Xns9576C0D2EB045asu1cornelledu@132.236.56.8>
Jim Keenan <jkeen_via_google@yahoo.com> wrote in
news:jcG7d.983$6y6.412@trndny02:
> A. Sinan Unur wrote:
>
>>
>> This script produces the following output:
>>
>> D:\Home\htdocs\test.cgi> perl tv.pl
>> Using [ operator ]:
...
>> Using [ object_oriented ]:
...
>> Using [ subroutine_interface ]:
...
>>
>> I would have expected the output to be identical in using all three
>> methods. I can't figure out why. Any ideas?
>>
>
> I confirm your results and your perplexity. Am I correct in thinking
> that the results you expected were those from the 'operator' interface?
>
> Jim Keenan
Thanks Jim. Your assumption is correct. At least now I know I am not the
only one :)
Sinan.
------------------------------
Date: 03 Oct 2004 00:13:41 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Regexp::Common OO interface
Message-Id: <slrncluh1l.hv.abigail@alexandra.abigail.nl>
A. Sinan Unur (usa1@llenroc.ude.invalid) wrote on MMMML September
MCMXCIII in <URL:news:Xns9576982A03C35asu1cornelledu@132.236.56.8>:
'' Hello All:
''
'' I am a little confused and would appreciate another set of eyes looking at
'' the following script and telling me what I am not getting:
''
'' #! perl
''
'' use strict;
'' use warnings;
''
'' use Regexp::Common qw(number RE_num_real);
''
'' my %validators = (
'' operator => sub {
'' my $v = shift;
'' if( $v =~ /^$RE{num}{real}{-keep}{-places => '0,2'}$/ ) {
'' print "matched!\n";
'' return $1;
'' }
'' return;
'' },
'' object_oriented => sub {
'' my $v = shift;
'' if( $RE{num}{real}{-keep}{-places => '0,2'}->matches($v) ) {
'' print "matched!\n";
'' return $1;
'' }
'' return;
'' },
'' subroutine_interface => sub {
'' my $v = shift;
'' if( $v =~ RE_num_real(-keep => 1, -places => '0,2') ) {
'' print "matched!\n";
'' return $1;
'' }
'' return;
'' },
'' );
''
'' my @values = qw(1 1.1 1.11 1.111);
''
'' for my $v (keys %validators) {
'' print "Using [ $v ]:\n";
'' for my $value (@values) {
'' if(defined (my $validated = $validators{$v}->($value))) {
'' print "$value\t: validated\n";
'' } else {
'' print "$value\t: not validated\n";
'' }
'' }
'' print "---\n";
'' }
'' __END__
''
'' This script produces the following output:
''
'' D:\Home\htdocs\test.cgi> perl tv.pl
'' Using [ operator ]:
'' matched!
'' 1 : validated
'' matched!
'' 1.1 : validated
'' matched!
'' 1.11 : validated
'' 1.111 : not validated
'' ---
'' Using [ object_oriented ]:
'' matched!
'' 1 : not validated
'' 1.1 : not validated
'' 1.11 : not validated
'' 1.111 : not validated
'' ---
'' Using [ subroutine_interface ]:
'' matched!
'' 1 : validated
'' matched!
'' 1.1 : validated
'' matched!
'' 1.11 : validated
'' matched!
'' 1.111 : validated
'' ---
''
'' I would have expected the output to be identical in using all three
'' methods. I can't figure out why. Any ideas?
For starters, you have anchored the "operator" expression, while you
haven't done so with the OO or subroutine interfaces. So, it's quite
logical that you find matches for each value when using the subroutine
interface.
As for the OO interface, that's probably a bug, because I'd expect to
find matches in all cases as well. In the two years I've been maintaining
Regexp::Common, I haven't heard of a single use of OO interface to the
patterns of Regexp::Common, and only one or two usages of sub routine
interface. They are therefore hardly tested (it would be a real pain in
the ass to make tests due to the fact they can't be anchored), so bugs
are bound to be plenty.
I'll put it on the TODO list.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: 3 Oct 2004 00:27:00 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Regexp::Common OO interface
Message-Id: <Xns9576D03FEB6B7asu1cornelledu@132.236.56.8>
Abigail <abigail@abigail.nl> wrote in
news:slrncluh1l.hv.abigail@alexandra.abigail.nl:
> A. Sinan Unur (usa1@llenroc.ude.invalid) wrote on MMMML September
> MCMXCIII in <URL:news:Xns9576982A03C35asu1cornelledu@132.236.56.8>:
> '' I would have expected the output to be identical in using all
> '' three methods. I can't figure out why. Any ideas?
>
> For starters, you have anchored the "operator" expression, while you
> haven't done so with the OO or subroutine interfaces. So, it's quite
> logical that you find matches for each value when using the subroutine
> interface.
OK, that makes sense.
> As for the OO interface, that's probably a bug, because I'd expect to
> find matches in all cases as well. In the two years I've been
> maintaining Regexp::Common, I haven't heard of a single use of OO
> interface to the patterns of Regexp::Common, and only one or two
> usages of sub routine interface. They are therefore hardly tested (it
> would be a real pain in the ass to make tests due to the fact they
> can't be anchored), so bugs are bound to be plenty.
So, I guess it would be prudent to stick with using the tied hash
interface.
Sinan.
------------------------------
Date: 2 Oct 2004 15:03:41 -0700
From: dutone@hotmail.com (dutone)
Subject: Re: removing empty split() fields
Message-Id: <7d56a4da.0410021403.6139fe96@posting.google.com>
Tad McClellan <tadmc@augustmail.com> wrote in message news:<slrncls0n6.20i.tadmc@magna.augustmail.com>...
> dutone <dutone@hotmail.com> wrote:
> > sample file:
> > +123n
> > blah blah blah
> > +123+
> > more blah
> > sasas
> > assa
> > +123+
> >
> > open IN, "data" or die $!;
> > my @data = <IN>;
> > my @splitData = split /\+123(?:\+)?/, "@data";
> ^ ^
> ^ ^
> ^ ^
what are you pointing out here?
> > for(@splitData) { print "LINE ** $_"; }
> >
> > prints:
> > LINE ** LINE ** n
> > blah blah blah
> > LINE **
> > more blah
> > sasas
> > assa
> > LINE **
>
>
> Yes...
>
> ... and what is it that you want it to print instead?
>
> Should we all just guess?
>
> I'll assume you don't want the extra space characters at the
> beginning of the lines after the first line?
Yes
> > now i understand that split returns the number of matched items plus 1
> > if no limit is given.
>
>
> That is not related to your problem in any way.
>
> > so in order to weed the empty elements
>
>
> There are no "empty elements" here. Each element in the list
> returned by split() is non-empty (ie. has length()).
>
>
>
> You put the extra space characters in yourself by interpolating
> the array.
>
> If you don't want them in there, then don't put them in there. :-)
>
>
> my @splitData = split /\+123(?:\+)?/, join "", @data;
still prints:
LINE ** LINE ** n
blah blah blah
LINE **
more blah
sasas
assa
LINE **
>
> or
>
> my @splitData;
> { local $" = "";
> @splitData = split /\+123(?:\+)?/, "@data";
> }
so does this
> or, do without the @data temporary array altogether:
>
> my @splitData;
> { local $/;
> @splitData = split /\+123(?:\+)?/, <IN>;
> }
>
this does as well.
>
> Yours is a Frequently Asked Question:
>
> perldoc -q spaces
>
> Why do I get weird spaces when I print an array of lines?
doing this:
my @splitData;
{ local $" = ":";
@splitData = split /\+123(?:\+)?/, "@data";
}
prints:
LINE ** LINE ** n
:blah blah blah
:LINE **
:more blah
:sasas
:assa
:LINE **
which leads me to think thats its not an interpolation problem. The
default $" interpolation would not cause an empty space at the
begining of the array. In my sample file '+123' is the first line, no
spaces , tabs etc... above it.
to be clear I do not want to print lines containg /^[^[:graph:]]$/
thanks....
------------------------------
Date: Sat, 2 Oct 2004 14:53:53 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Syntax appears inconsistent - why is this?
Message-Id: <Pine.SOL.3.96.1041002145013.7337A-100000@vcmr-86.server.rpi.edu>
On Sat, 2 Oct 2004, John W. Kennedy wrote:
>Abigail wrote:
>> Eh, wrong. () seldomly build lists. It certainly doesn't in:
>
>> my %hash = (key1 => 'val1', key2 => 'val2');
>
>> The parens in the above expression play exactly the same role as
>> they do in:
>>
>> my $val = 3 * (4 + 5);
>
>No, the () /are/ building a list above. The statement is syntactic
>sugar for:
>
> my %hash = ('key1', 'val1', 'key2', 'val2');
The parentheses *are* being used precendence-wise, as Abigail is stating.
The only thing that makes the right-hand side of the hash assignment a
list is the fact the the left-hand side is assignment to a hash.
my %hash = 1;
There's a one-element list on the right-hand side.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
Senior Dean, Fall 2004 % have long ago been overpaid?
RPI Corporation Secretary %
http://japhy.perlmonk.org/ % -- Meister Eckhart
------------------------------
Date: 02 Oct 2004 23:44:45 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Syntax appears inconsistent - why is this?
Message-Id: <slrnclufbd.hv.abigail@alexandra.abigail.nl>
John W. Krahn (someone@example.com) wrote on MMMML September MCMXCIII in
<URL:news:3fu7d.3191$N%.2983@edtnps84>:
^^ Abigail wrote:
^^ > Joe Smith (Joe.Smith@inwap.com) wrote on MMMMXLVIII September MCMXCIII in
^^ > <URL:news:TeS6d.146050$D%.55455@attbi_s51>:
^^ > %%
^^ > %% I would phrase it differently.
^^ > %% ( ) are used to build lists, which can populate arrays and hashes.
^^ >
^^ > Eh, wrong. () seldomly build lists. It certainly doesn't in:
^^ >
^^ > my %hash = (key1 => 'val1', key2 => 'val2');
^^ >
^^ > The parens in the above expression play exactly the same role as
^^ > they do in:
^^ >
^^ > my $val = 3 * (4 + 5);
^^ >
^^ > They help the parser to construct a parse-tree.
^^
^^ Could you (or anyone) explain what the inner parentheses are doing in the
^^ second example and why please?
^^
^^ while () { print "infinite loop\n" }
This is special cased.
^^ while (()) { print "will not print\n" }
This is why I wrote 'seldomly' instead of 'never'.
Abigail
--
@_=map{[$!++=>$_^$/]}split$²=>"\@\x7Fy~*kde~box*Zoxf*Bkiaox";$\="\r";
$|=++$*;do{($#=>$=)=(rand@_=>rand@_);@_[$#,$=]=@_[$=,$#]}for($*..@_);
for$:($|..@_-$|){for($|..@_-$:){@_[$_-$|,$_]=@_[$_=>$_-$*]if$_[$_][$¼
]<$_[$_-$*][$®];print+map{$_->[$|]}@_;select$·,$°,$½,"$[.$|"}}print$/
------------------------------
Date: 02 Oct 2004 23:50:18 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: While query
Message-Id: <slrncluflq.hv.abigail@alexandra.abigail.nl>
A. Sinan Unur (usa1@llenroc.ude.invalid) wrote on MMMML September
MCMXCIII in <URL:news:Xns9575F3378167Aasu1cornelledu@132.236.56.8>:
}} Abigail <abigail@abigail.nl> wrote in
}} news:slrnclrjgf.hv.abigail@alexandra.abigail.nl:
}}
}} > A. Sinan Unur (1usa@llenroc.ude.invalid) wrote on MMMMXLIX September
}} > MCMXCIII in <URL:news:Xns957588191B864asu1cornelledu@132.236.56.8>:
}}
}} > !! "P.R.Brady" <iss025@bangor.ac.uk> wrote in
}} > !! news:415D9051.60300@bangor.ac.uk:
}}
}} > !! > So to empty and process my array/stack I need to:
}} > !! > while (scalar(@array)) {
}} > !! > $_=pop(@array);
}} > !! > ...
}} > !! > }
}} > !!
}} > !! You could do
}} > !!
}} > !! use strict;
}} > !! use warnings;
}} > !!
}} > !! my @array = ('hello', '');
}} > !!
}} > !! while(@array and my ($x) = pop @array) {
}} > !! print "Popped: [$x]\n";
}} > !! }
}} > !!
}} > !! __END__
}} >
}} > Tricky. And not very nice to post this without explaining why this
}} > works. (It won't work if you remove the parens around the '$x').
}}
}} Well, I know you know why it works, but I also see the point of your
}} remark, so here it goes. Consider the condition in the while statement:
}}
}} @array and my ($x) = pop @array
}}
}} @array in this context returns the number of elements in the array. Only if
}} the number of elements in @array is greater than zero will the right hand
}} side above will be evaulated.
}}
}} my ($x) = pop @array;
}}
}} pops an element off @array, puts it in $x, and returns the single element
}} list ($x). Hence, the RHS is always true, if @array has any elements. This
}} way, the while-loop does not prematurely abort if one of the elements in
}} the list is undefined.
Eh, no. The assignment is done in scalar context, and you can't have
lists in scalar context. A list assignment in scalar context returns
the number of elements on the right hand side of the assignment. And
that, in this case, is always 1.
This is way a trick like:
my $count = () = $str =~ /foo/g;
works.
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
------------------------------
Date: 02 Oct 2004 23:52:22 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: While query
Message-Id: <slrnclufpm.hv.abigail@alexandra.abigail.nl>
Jeff 'japhy' Pinyan (pinyaj@rpi.edu) wrote on MMMML September MCMXCIII in
<URL:news:Pine.SOL.3.96.1041002110541.3684A-100000@vcmr-86.server.rpi.edu>:
## On 1 Oct 2004, A. Sinan Unur wrote:
##
## >"P.R.Brady" <iss025@bangor.ac.uk> wrote in
## >news:415D9051.60300@bangor.ac.uk:
## >
## >> So to empty and process my array/stack I need to:
## >> while (scalar(@array)) {
## >> $_=pop(@array);
## >> ...
## >> }
## >
## >You could do
## >
## >use strict;
## >use warnings;
## >
## >my @array = ('hello', '');
## >
## >while(@array and my ($x) = pop @array) {
## > print "Popped: [$x]\n";
## >}
##
## No, he couldn't. It *still* breaks out of the while conditional when
## pop() returns a false element.
Nope. You would be right if he had written:
while(@array and my $x = pop @array) { .. }
because an assignment in scalar context returns the thing being assigned.
But due to the parenthesis, the assignment is in *list* context. And that
returns the number of elements on the right-hand side. Which is always 1.
Run it, and you'll see.
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: 2 Oct 2004 23:54:48 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: While query
Message-Id: <Xns9576CACACC604asu1cornelledu@132.236.56.8>
Abigail <abigail@abigail.nl> wrote in
news:slrncluflq.hv.abigail@alexandra.abigail.nl:
> A. Sinan Unur (usa1@llenroc.ude.invalid) wrote on MMMML September
> MCMXCIII in <URL:news:Xns9575F3378167Aasu1cornelledu@132.236.56.8>:
> }} my ($x) = pop @array;
> }}
> }} pops an element off @array, puts it in $x, and returns the single
> }} element list ($x). Hence, the RHS is always true, if @array has
> }} any elements.
> Eh, no. The assignment is done in scalar context,
Which is why the RHS is always 1, i.e. true. I am sorry if I wasn't clear.
Sinan.
------------------------------
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 7202
***************************************