[23015] in Perl-Users-Digest
Perl-Users Digest, Issue: 5235 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 18 00:05:58 2003
Date: Thu, 17 Jul 2003 21: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 Thu, 17 Jul 2003 Volume: 10 Number: 5235
Today's topics:
File::Find is slower than using recursion!? <stevea@wrq.com>
Re: File::Find is slower than using recursion!? (Sam Holden)
Forcing Alphanumeric Text Entry (sekdab)
Re: Forcing Alphanumeric Text Entry <jkeen@concentric.net>
Re: Forcing Alphanumeric Text Entry <parv_fm@emailgroupsWhereElse.net>
Re: Forcing Alphanumeric Text Entry <jkeen@concentric.net>
Re: Forcing Alphanumeric Text Entry <asu1@c-o-r-n-e-l-l.edu>
Re: Forcing Alphanumeric Text Entry <me@home.com>
Re: Forcing Alphanumeric Text Entry <jkeen@concentric.net>
Re: Forcing Alphanumeric Text Entry <me@home.com>
Re: Forcing Alphanumeric Text Entry <jkeen@concentric.net>
How to match all characters in a Character Class (Chinna Polinati)
Re: How to match all characters in a Character Class <trammell+usenet@hypersloth.invalid>
Re: How to match all characters in a Character Class <emschwar@pobox.com>
Re: HTML REGEX <SineSwiper@ResonatorSoft.org>
JOIN problem ? (2nd attempt to post) (stu7)
Re: JOIN problem ? (2nd attempt to post) <asu1@c-o-r-n-e-l-l.edu>
Re: JOIN problem ? (2nd attempt to post) <pinyaj@rpi.edu>
Re: macros in perl <REMOVEsdnCAPS@comcast.net>
Re: macros in perl <tassilo.parseval@rwth-aachen.de>
Re: macros in perl <uri@stemsystems.com>
Makefile for 5.6 when 5.004 is default (Pete Butler)
Re: Makefile for 5.6 when 5.004 is default (Sam Holden)
Re: perlstyles <skuo@mtwhitney.nsc.com>
Re: perlstyles <parv_fm@emailgroupsWhereElse.net>
Re: Removing Perl comments and strings using regexps <SineSwiper@ResonatorSoft.org>
Re: Test for file existence (stu7)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Jul 2003 00:44:11 GMT
From: Steve Allan <stevea@wrq.com>
Subject: File::Find is slower than using recursion!?
Message-Id: <uwuegu0it.fsf@wrq.com>
One of my colleagues who is new to Perl wrote a script that used
recursion to do what File::Find is designed to do (he didn't know
about File::Find). He sent it to me, and I sent him back a new
version using File::Find. He later wrote back that my version was
SLOWER!
Skeptical, I reduced both scripts to versions that simply search for
files and put them into an array. I then benchmarked the two and he
was right. Here's what cmpthese() reported using 20 iterations:
s/iter File::Find Recursion
File::Find 5.19 -- -70%
Recursion 1.58 229% --
Is poor performance a known problem with File::Find, or am I using it
improperly? It's hard to believe it could be slower than recursion.
Any insights on why I'm seeing such a discrepancy?
I'm using ActiveState perl, version 5.8.0 on Window XP.
Below is the benchmark script I used. The variable $rootdir is set to
a directory on my machine that contains over 12000 files and numerous
subdirectories. You should only have to modify that one line to run
the script - if you're so inclined :^)
Thanks.
--
-- Steve
#!/usr/bin/perl -w
use strict;
use Benchmark qw(:all) ;
my $rootdir = 'd:/projects/vhi/griffin/dev';
chdir $rootdir or die "Can't change to $rootdir: $!";
cmpthese (20, {
'File::Find' => \&findfiles,
'Recursion' => \&recurse,
}
);
#findfiles();
#recurse();
#======================================================================
# New version uses File::Find
#======================================================================
sub findfiles {
use File::Find;
my @flist;
# search for files not in have list
find (sub { push @flist => $File::Find::name if -f }, '.');
print "In Findfiles: found ", scalar @flist, " files\n";
}
#======================================================================
# Old version uses recursion
#======================================================================
my @globallist;
sub recurse {
use Cwd;
@globallist = ();
# recurse through sub directories checking for known files
opendir CURRENTDIR, "." or die "Cannot open directory ", cwd(), ":! ";
my @files = grep !/^\.\.?$/, readdir CURRENTDIR;
closedir CURRENTDIR;
for (@files) {
checkFile($_, '.');
}
print "In Recurse: found ", scalar @globallist, " files\n";
}
sub checkFile {
my $fileToCheck = $_[0];
my $currentP4Dir = $_[1];
# first see if it is a directory
if ( chdir $fileToCheck == 1 ) {
$currentP4Dir = $currentP4Dir."/".$fileToCheck;
# go through the new directory
opendir CURRENTDIR, "." or die "Cannot open directory ".cwd();
my @files = grep !/^\.\.?$/, readdir CURRENTDIR;
closedir CURRENTDIR;
for (@files) {
checkFile($_, $currentP4Dir);
}
# after finishing, go up a directory
chdir "..";
$currentP4Dir =~ s/^(.*)\/.*$/$1/;
}
else {
#print "$fileToCheck\n";
push @globallist => $fileToCheck;
}
}
#=================================== EOF ======================================
------------------------------
Date: 18 Jul 2003 01:57:41 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: File::Find is slower than using recursion!?
Message-Id: <slrnbhel0l.9q8.sholden@flexal.cs.usyd.edu.au>
On Fri, 18 Jul 2003 00:44:11 GMT, Steve Allan <stevea@wrq.com> wrote:
> One of my colleagues who is new to Perl wrote a script that used
> recursion to do what File::Find is designed to do (he didn't know
> about File::Find). He sent it to me, and I sent him back a new
> version using File::Find. He later wrote back that my version was
> SLOWER!
>
> Skeptical, I reduced both scripts to versions that simply search for
> files and put them into an array. I then benchmarked the two and he
> was right. Here's what cmpthese() reported using 20 iterations:
>
> s/iter File::Find Recursion
> File::Find 5.19 -- -70%
> Recursion 1.58 229% --
>
> Is poor performance a known problem with File::Find, or am I using it
> improperly? It's hard to believe it could be slower than recursion.
> Any insights on why I'm seeing such a discrepancy?
I'll take correct over fast any day.
The recursive version doesn't work in the presence of symlink loops.
Where doesn't work means infinitely recurses (well I guess it will run
out of stack or memory at some point).
I'll also take 1 line of code over 30 odd lines, and worry about
speed if it turns out to be not fast enough for a given task.
I've never used File::Find so I don't know if your usage is correct or
not...
[snip code]
--
Sam Holden
------------------------------
Date: 17 Jul 2003 18:42:18 -0700
From: seldan@lore.cc (sekdab)
Subject: Forcing Alphanumeric Text Entry
Message-Id: <4b21880f.0307171742.56e340c9@posting.google.com>
Hello all.
Disclaimer, I am a Perl newbie. Though I know a good deal of shell,
and some PHP, Perl is, otherwise, new territory for me.
I've gone ahead and loaded the CGI.pm module and, as a test, am
creating a small password change screen. Everything was fine and I
had the page up and running in no time. I did this to focus a bit on
security, and was wondering what the best way would be to force limit
the characters entered to alphanumeric.
I.e. I want to prevent someone from using "tom ; cat /etc/passwd" as a
password because this data is being passed to a shell.
I've just started readingp on regular expressions and can probably
figure out a convoluted way to do this; just wanted some hints as to
how others have done this in the past.
Thanks for the help.
Tom
------------------------------
Date: 18 Jul 2003 02:08:24 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <bf7kqo$gca@dispatch.concentric.net>
"sekdab" <seldan@lore.cc> wrote in message
news:4b21880f.0307171742.56e340c9@posting.google.com...
> Hello all.
>
> I did this to focus a bit on
> security, and was wondering what the best way would be to force limit
> the characters entered to alphanumeric.
>
> I.e. I want to prevent someone from using "tom ; cat /etc/passwd" as a
> password because this data is being passed to a shell.
>
> I've just started readingp on regular expressions and can probably
> figure out a convoluted way to do this; just wanted some hints as to
> how others have done this in the past.
>
Subject to the caveat that I haven't had to deal with password security ...
in general, the way you would test for alphanumericness would be something
like:
if ($input =~ /^[A-Za-z0-0]+$/) {
# do something with $input;
} else { die "$input is invalid input: $!" }
Note that this would forbid all punctuation characters.
------------------------------
Date: Fri, 18 Jul 2003 02:24:56 GMT
From: parv <parv_fm@emailgroupsWhereElse.net>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <slrnbhemp4.h49.parv_fm@localhost.holy.cow>
in message <bf7kqo$gca@dispatch.concentric.net>,
wrote James E Keenan ...
> in general, the way you would test for alphanumericness would be
> something like:
> if ($input =~ /^[A-Za-z0-0]+$/) {
^ ^
^ ^
A typo there: [0-0] in place of [0-9]?
> # do something with $input;
> } else { die "$input is invalid input: $!" }
--
In order to reach me, do away w/ WhereElse in the address.
A programmer, budding Unix system administrator, and amateur photographer
is in search of employment: http://www103.pair.com/parv/work/
------------------------------
Date: 18 Jul 2003 02:33:50 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <bf7mae$gc3@dispatch.concentric.net>
"parv" <parv_fm@emailgroupsWhereElse.net> wrote in message
news:slrnbhemp4.h49.parv_fm@localhost.holy.cow...
> in message <bf7kqo$gca@dispatch.concentric.net>,
> wrote James E Keenan ...
>
> > in general, the way you would test for alphanumericness would be
> > something like:
> > if ($input =~ /^[A-Za-z0-0]+$/) {
> ^ ^
> ^ ^
> A typo there: [0-0] in place of [0-9]?
Yes. Good catch.
------------------------------
Date: 18 Jul 2003 02:34:12 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <Xns93BBE599CDDBCasu1cornelledu@132.236.56.8>
parv <parv_fm@emailgroupsWhereElse.net> wrote in
news:slrnbhemp4.h49.parv_fm@localhost.holy.cow:
> in message <bf7kqo$gca@dispatch.concentric.net>,
> wrote James E Keenan ...
>
>> in general, the way you would test for alphanumericness would be
>> something like:
>> if ($input =~ /^[A-Za-z0-0]+$/) {
> ^ ^
> ^ ^
> A typo there: [0-0] in place of [0-9]?
Wouldn't it be better to use /^\w+$/ ?
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Thu, 17 Jul 2003 22:38:13 -0700
From: Steve <me@home.com>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <uh1fhvkfuh82tu1tpa1gie6rv54h166k0g@4ax.com>
Hi Tom,
I'm still kind of new to this, but have been reading up on the topic.
For security, you want to first investigate using the -T taint switch:
#!/usr/bin/perl -Tw
This now makes the script die if unsafe data (input from outside of
the script) is used in a dangerous way.
Then, to untaint the data, you need to use backreferences (I think
this is what it is called):
if ($key =~ /^([-_\w\s]+)$/) {
$key = $1
} else {
bad_data ($bad_string)
}
basically, in a regex, something surrounded in a parans () is placed
into the varible $1, so /^([-_\w\s]+)$/ will only allow alphanumeric
input, the space and the dash or underscore. If this is correct, the
input is placed into $1 and then you untaint the varible:
$key = $1
On 17 Jul 2003 18:42:18 -0700, seldan@lore.cc (sekdab) wrote:
>Hello all.
>
>Disclaimer, I am a Perl newbie. Though I know a good deal of shell,
>and some PHP, Perl is, otherwise, new territory for me.
>
>I've gone ahead and loaded the CGI.pm module and, as a test, am
>creating a small password change screen. Everything was fine and I
>had the page up and running in no time. I did this to focus a bit on
>security, and was wondering what the best way would be to force limit
>the characters entered to alphanumeric.
>
>I.e. I want to prevent someone from using "tom ; cat /etc/passwd" as a
>password because this data is being passed to a shell.
>
>I've just started readingp on regular expressions and can probably
>figure out a convoluted way to do this; just wanted some hints as to
>how others have done this in the past.
>
>Thanks for the help.
>Tom
------------------------------
Date: 18 Jul 2003 02:39:08 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <bf7mkc$gc9@dispatch.concentric.net>
"A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu> wrote in message
news:Xns93BBE599CDDBCasu1cornelledu@132.236.56.8...
> parv <parv_fm@emailgroupsWhereElse.net> wrote in
> news:slrnbhemp4.h49.parv_fm@localhost.holy.cow:
>
> > in message <bf7kqo$gca@dispatch.concentric.net>,
> > wrote James E Keenan ...
> >
> >> in general, the way you would test for alphanumericness would be
> >> something like:
> >> if ($input =~ /^[A-Za-z0-0]+$/) {
> > ^ ^
> > ^ ^
> > A typo there: [0-0] in place of [0-9]?
>
> Wouldn't it be better to use /^\w+$/ ?
>
I responded on the assumption that OP wanted strictly alphanumeric
characters. Perl's \w adds
'_' to the character class [A-Za-z0-9]. If '_' is permissible input for his
problem, then it -- and no other punctuation characters -- can indeed be
allowed with \w
------------------------------
Date: Thu, 17 Jul 2003 22:50:31 -0700
From: Steve <me@home.com>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <7i2fhvsl064ksrprnc3lfnrpi6ci6a138h@4ax.com>
On Thu, 17 Jul 2003 22:38:13 -0700, Steve <me@home.com> wrote:
whoops...make that:
if ($key =~ /^([-_\w\s]+)$/) {
$key = $1
} else {
bad_data ($key)
}
I'm rewriting that, so had $string as input to my function bad_data
instead of $key ;-)
------------------------------
Date: 18 Jul 2003 02:51:55 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Forcing Alphanumeric Text Entry
Message-Id: <bf7ncb$gc4@dispatch.concentric.net>
"Steve" <me@home.com> wrote in message
news:uh1fhvkfuh82tu1tpa1gie6rv54h166k0g@4ax.com...
> Hi Tom,
>
> I'm still kind of new to this, but have been reading up on the topic.
> For security, you want to first investigate using the -T taint switch:
>
> #!/usr/bin/perl -Tw
>
> This now makes the script die if unsafe data (input from outside of
> the script) is used in a dangerous way.
>
> Then, to untaint the data, you need to use backreferences (I think
> this is what it is called):
>
> if ($key =~ /^([-_\w\s]+)$/) {
> $key = $1
> } else {
> bad_data ($bad_string)
> }
>
Right code; wrong terminology. $1 is a 'match variable': it captures what
was matched in the 1st pair of parentheses and stores it in a variable. A
backreference (written \1 \2 \3 and so on) is a way of re-using a match
within the same regular expression pattern.
my $string = 'aaabacabad';
# my $string = 'aaabacad';
if ($string =~ /(ab).*\1/) {
print "Pattern matched in $string\n";
my $cap = $1;
print "$cap was captured\n";
} else {
print "Out of luck, buddy\n";
}
------------------------------
Date: 17 Jul 2003 15:43:33 -0700
From: chinbp@yahoo.com (Chinna Polinati)
Subject: How to match all characters in a Character Class
Message-Id: <b70b52ab.0307171443.6fe60d4f@posting.google.com>
Is there a way in Perl to match all the characters in the Character Class?
thanks,
Chinna
------------------------------
Date: Thu, 17 Jul 2003 23:05:15 +0000 (UTC)
From: "John J. Trammell" <trammell+usenet@hypersloth.invalid>
Subject: Re: How to match all characters in a Character Class
Message-Id: <slrnbheatb.pj6.trammell+usenet@hypersloth.el-swifto.com.invalid>
On 17 Jul 2003 15:43:33 -0700, Chinna Polinati <chinbp@yahoo.com> wrote:
> Is there a way in Perl to match all the characters in the Character
> Class?
>
.
------------------------------
Date: 17 Jul 2003 17:24:06 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: How to match all characters in a Character Class
Message-Id: <etok7agrb3d.fsf@wormtongue.emschwar>
"John J. Trammell" <trammell+usenet@hypersloth.invalid> writes:
> On 17 Jul 2003 15:43:33 -0700, Chinna Polinati <chinbp@yahoo.com> wrote:
> > Is there a way in Perl to match all the characters in the Character
> > Class?
>
> .
No, that matches any single character. The OP was asking about
character classes, such as [a0-9q] and [:space:], and so forth. To do
that, you'd need a way to enumerate them, and I don't know how to do
that (I don't think it's possible, but ICBW, and probably am).
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Fri, 18 Jul 2003 00:22:34 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: HTML REGEX
Message-Id: <e5HRa.77120$wk6.17873@rwcrnsc52.ops.asp.att.net>
Boudga wrote:
> I want to remove the Style tags from my HTML files so I wrote this Perl
> script to remove the line breaks and attempt to remove the Style tags but it
> fails....any help would be much appreciated!
I've got one that does that:
$j =~ s/<+\s*STYLE(.*?)>+.+<+\s*\/STYLE(.*?)>+//gis
Should remove the style tags and any contents thereof.
--
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>
------------------------------
Date: 17 Jul 2003 17:34:35 -0700
From: stuseven@hotmail.com (stu7)
Subject: JOIN problem ? (2nd attempt to post)
Message-Id: <d7dd90b0.0307171634.6532ff1d@posting.google.com>
+ (I posted this the other day, but it seems to have
dissappeared).
Using my older version of Perl (5.08 ?), the JOIN
command produces what appears to be more like a HASH
than the ordered list I fed it... for instance;
@fruitz = join "apple","bananna","cherry" ;
...does in fact produce a joined string, but the elements
are NEVER in the original order,
- more often, this would come out: apple cherry bananna
when printed ...suggesting to me that, at least this older
version of Perl, that JOIN used a HASH to save the results.
That seems a little odd_ but really, my question is,
IS this what the JOIN command always does, or is it fixed
or changed in later versions of Perl, 5.6 or later ?
------------------------------
Date: 18 Jul 2003 01:03:31 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <Xns93BBD63959D45asu1cornelledu@132.236.56.8>
stuseven@hotmail.com (stu7) wrote in
news:d7dd90b0.0307171634.6532ff1d@posting.google.com:
> + (I posted this the other day, but it seems to have
> dissappeared).
>
> Using my older version of Perl (5.08 ?), the JOIN
> command produces what appears to be more like a HASH
> than the ordered list I fed it... for instance;
>
> @fruitz = join "apple","bananna","cherry" ;
Take a look at the documentation for join:
join EXPR,LIST
Joins the separate strings of LIST into a single string with
fields separated by the value of EXPR, and returns that new
string. Example:
$rec = join(':', $login,$passwd,$uid,$gid,$gcos,$home,$shell);
Beware that unlike "split", "join" doesn't take a pattern as its
first argument. Compare "split".
you should see that join returns a single string in scalar context.
Now, the first argument to join is taken to be the field separator you
want to use. Hence:
my $fruitz = join "apple","bananna","cherry" ;
print $fruitz;
yields:
banannaapplecherry
because you have told Perl you want to have banana and cherry separated
by apple.
Now, by assigning the return value of join to an array you are creating
an array with the single element "banannaapplecherry".
> - more often, this would come out: apple cherry bananna
> when printed ...
That sounds impossible to me.
> That seems a little odd_ but really, my question is,
> IS this what the JOIN command always does, or is it fixed
> or changed in later versions of Perl, 5.6 or later ?
I don't see what needs to be fixed other than your code. If you just want
to join "apple","bananna" and "cherry" with no separators in between, use
join "", "apple","bananna","cherry" ;
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Thu, 17 Jul 2003 21:04:32 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: stu7 <stuseven@hotmail.com>
Subject: Re: JOIN problem ? (2nd attempt to post)
Message-Id: <Pine.SGI.3.96.1030717210301.64908A-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On 17 Jul 2003, stu7 wrote:
> Using my older version of Perl (5.08 ?), the JOIN
> command produces what appears to be more like a HASH
> than the ordered list I fed it... for instance;
>
> @fruitz = join "apple","bananna","cherry" ;
First of all, join() returns a scalar. Why are you storing ONE scalar in
an array? It's not "wrong", it's just suspect. I don't think you're
doing what you think you're doing.
Second, you've left out the first argument to join(), which is the string
with which to join the other strings.
print join " -- ", qw( apple banana cherry );
# apple -- banana -- cherry
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Thu, 17 Jul 2003 17:19:00 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: macros in perl
Message-Id: <Xns93BBBA4B9193Asdn.comcast@206.127.4.25>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Abigail <abigail@abigail.nl> wrote in
news:slrnbhcv33.53v.abigail@alexandra.abigail.nl:
> And a single observation makes you conclude that macros can't
> make the source clearer?
Far from being a single data point, that was an *example* of the problem,
as is the OP's hack. My conclusion was not based on that single example,
but on my career-long observations.
> Do you also think that 'Switch.pm' shouldn't be included in the
> main distribution? After all, that makes use of a source filter,
> which is a source preprocessor just like cpp or m4.
>
> What about modules in general? Should people stop using Socket,
> and just learn the goddamn language and use socket() and
> bind (), they way some god intended?
Oh good grief. I wasn't making the case that syntax should be fixed
in stone, nor that value cannot be added by libraries or macros or
anything else. My flame was about a newbie not understanding the
language and shoehorning it into his preconceived notions, and thereby
both obfuscating the language and hindering his future understanding.
Damien Conway was not a newbie who didn't understand Perl when he
wrote the (excellent) Switch module. Most source filters are toys (eg
all or nearly all of the Acme hierarchy), but it's an excellent tool when
well used. Before the OP rewrites the syntax of Perl, he should learn
it, wallow in it, grok it, and then use the languages tools (modules,
source filters, XS, what-have-you) if he still has good ideas for
improvement.
Perl is a wonderfully flexible and extensible language that is not
well served by simplistic attempts to make the language look like
something else without adding value.
- --
Eric
$_ = reverse sort qw p ekca lre Js reh ts
p, $/.r, map $_.$", qw e p h tona e; print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPxcgxmPeouIeTNHoEQIMaQCdFWJ0LdgUZ/BqUTN7WZzKHcZOCUoAoNfD
Yre4v79tYKc71oUZdhkcluXl
=G2Yb
-----END PGP SIGNATURE-----
------------------------------
Date: 17 Jul 2003 22:26:36 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: macros in perl
Message-Id: <bf77qs$di2$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Uri Guttman:
>>>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:
>
> TvP> Perl6 will have macros, wont it? I think that should give some
> TvP> indication that they are even useful for such non-repetitive
> TvP> languages as Perl is.
>
> and they will be very cool too. the definition of a macro in perl6 is
> that it is just a sub that executes as soon as it is parsed (in the
> compile phase). this integrates the macro concept into perl6 in a very
> neat way. if the macro returns a string, it replaces the original macro
> call. if it returns a code block (all blocks are code refs in perl6), it
> inserts that compiled opcode tree at this point in the main tree.
Hmmh. So if a macro in Perl6 is a function (that might return a string),
I can use Perl's text-manipulation capabilities to generate the
replacement-string. That's more than just "very cool"!
I really should stop hearing about Perl6. The more I hear about its new
features the more I get mad that I have to wait for it. I want it now!
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: Thu, 17 Jul 2003 23:21:10 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: macros in perl
Message-Id: <x7isq0hh95.fsf@mail.sysarch.com>
>>>>> "TvP" == Tassilo v Parseval <tassilo.parseval@rwth-aachen.de> writes:
TvP> Hmmh. So if a macro in Perl6 is a function (that might return a string),
TvP> I can use Perl's text-manipulation capabilities to generate the
TvP> replacement-string. That's more than just "very cool"!
yes! so you have the full power of perl inside the macro! and you can
control how it looks in the source by changing its parsing which is even
more powerful. we saw examples at oscon such as creating a new comment
char (other than #). you just made a macro that parses the char to
newline and returns an empty string.
TvP> I really should stop hearing about Perl6. The more I hear about its new
TvP> features the more I get mad that I have to wait for it. I want it now!
then you will either have to wait or help out with parrot.
another neat thing announced at oscon was damian has created a perl5
module that does most/many of the things in perl6 grammars! so the perl6
people will be able to write a perl6 parser in perl6 grammar and
generate a full parse tree for a code generator (to parrot, of course!).
that will speed up the bootstrapping of perl6 by a good amount.
and parrot is about to get objects and events and will be ready for real
languages soonish. perl6 (very pre-alpha prototype) is nearer than some
would expect).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 17 Jul 2003 16:31:54 -0700
From: pmbutler@attbi.com (Pete Butler)
Subject: Makefile for 5.6 when 5.004 is default
Message-Id: <9b766f0.0307171531.fc83deb@posting.google.com>
The server I'm working on provides perl 5.00401 as a default (it's
what /usr/bin/perl points to), but I've decided it's in my best
interest to use a later version (5.6.1 is also available).
I'm pulling stuff off CPAN and doing the whole "perl Makefile.PL /
make / etc." dance. What options do I need to set to get the
resulting code pointed at 5.6.1 rather than 5.00401? (And no,
re-setting /usr/bin/perl to point to /usr/bin/perl5.6.1 is NOT an
option; it's a third-party server.)
Thanks in advance,
-- Pete Butler
------------------------------
Date: 17 Jul 2003 23:38:57 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Makefile for 5.6 when 5.004 is default
Message-Id: <slrnbhecsh.as4.sholden@flexal.cs.usyd.edu.au>
On 17 Jul 2003 16:31:54 -0700, Pete Butler <pmbutler@attbi.com> wrote:
> The server I'm working on provides perl 5.00401 as a default (it's
> what /usr/bin/perl points to), but I've decided it's in my best
> interest to use a later version (5.6.1 is also available).
>
> I'm pulling stuff off CPAN and doing the whole "perl Makefile.PL /
> make / etc." dance. What options do I need to set to get the
> resulting code pointed at 5.6.1 rather than 5.00401? (And no,
> re-setting /usr/bin/perl to point to /usr/bin/perl5.6.1 is NOT an
> option; it's a third-party server.)
Run "/path/to/5.6.1/perl Makefile.PL"
And it should automagically work.
If I'm confused (and hence wrong) then setting /path/to/5.6.1 to be in
your path before /usr/bin before running the Makefile.PL will ceraintly
work.
--
Sam Holden
------------------------------
Date: Thu, 17 Jul 2003 16:02:46 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: perlstyles
Message-Id: <Pine.GSO.4.21.0307171556530.2297-100000@mtwhitney.nsc.com>
On 17 Jul 2003, Tassilo v. Parseval wrote:
...
> > i prefer quotes all the time for fixed string hash keys. combination of
> > old habit and being cautious. i have seen issues where a key was also a
> > function name and with quotes you know which one it is (even if it works
> > the way you want).
>
> Is that a problem actually? I tend to have problems with the opposite
> case: Where something is meant to be a keyword but perl treats it as a
> string, as in
>
> $hash{ shift } = 1;
>
> That leads to some contortions like
>
> $hash{ +shift } = 1;
>
> etc.
>
> I've lately come to use quotes, too. My reason is the syntax-highlighter
> of vim that marks hash-keys in the same color as strings only when they
> are enclosed in some pair of quotation marks. Otherwise they wont get
> colored at all.
>
I also quote hash keys after having encountered the dreaded
'vstring':
my %hash = (
t10 => 'Tiger',
t20 => 'Turtle',
u10 => 'Urchin',
v10 => 'Viper', # !! does not quote LHS of => !!
);
print keys %hash;
--
Regards,
Steven
------------------------------
Date: Fri, 18 Jul 2003 03:14:08 GMT
From: parv <parv_fm@emailgroupsWhereElse.net>
Subject: Re: perlstyles
Message-Id: <slrnbhepkr.h49.parv_fm@localhost.holy.cow>
in message <g1udhv065eijbi9kd4flhr3k2o1n19uoa7@4ax.com>,
wrote Matija Papec ...
>
> I was wandering what would be more readable for code maintainers, I
> prefer first as it's far more obvious what's going on(not to mention
> typing laziness), but that's just me.
>
> #1
> @arr = join ',', map s|'|\\'|g && "'$_'", grep /^MB/, @arr;
> #2
> @arr = join(',', map(s|'|\\'|g && "'$_'", grep(/^MB/, @arr)));
In this case, i would like to show that the output place is same as
input (use of map/grep BLOCK is intentional to avoid distracting
commas & parentheses)...
@arr = join ',' , map { s/'/\\'/g; "'$_'" }
grep { /^MB/ }
@arr;
Number & position of parentheses depends on what is being emphasized,
need to preserve order of execution, and grouping of pieces in a
larger expression. Example of the last criterion...
@arr =
join ',' , map ( s/'/\\'/g && "'$_'" ) , (grep ( /^MB/ ) , @arr);
(I maintain only my own code, what would i know.)
> and another one, how do you prefer $h{key} over $h{'key'} in case
> where key is strictly English \w class?
I used to use bare keys, but after the irritating error message about
usage of a key w/ a hyphen in its name, i use quoted keys w/o
exception.
- parv
--
In order to reach me, do away w/ WhereElse in the address.
A programmer, budding Unix system administrator, and amateur photographer
is in search of employment: http://www103.pair.com/parv/work/
------------------------------
Date: Fri, 18 Jul 2003 00:18:51 GMT
From: Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Subject: Re: Removing Perl comments and strings using regexps
Message-Id: <L1HRa.77103$wk6.17894@rwcrnsc52.ops.asp.att.net>
Jay Tilton wrote:
> Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org> wrote:
>
> : I'm in the middle of fixing the LXR tool to work with Perl. Almost
> : finished, but I've ran into a problem that completely fries my brain.
> : In order to detect Perl subroutine/variable declarations, I need to
> : remove comments and strings so that they don't get confused for
> : declarations.
>
> How about just running the program through the Xref backend?
>
> perl -MO=Xref foo.pl
>
Interesting. Is there a way to load that as a module and send the input
of a variable (the program) to Xref?
--
Brendan Byrd/SineSwiper <SineSwiper@ResonatorSoft.org>
Perl hacker, computer wizard, and all-around internet guru
Resonator Software <http://www.ResonatorSoft.org/>
------------------------------
Date: 17 Jul 2003 17:43:46 -0700
From: stuseven@hotmail.com (stu7)
Subject: Re: Test for file existence
Message-Id: <d7dd90b0.0307171643.6cca1620@posting.google.com>
*** ha ! I tried-> if (-ans $thispost)
*** if answer exist returned 0 :)
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<IgxRa.18833$kI5.8508@nwrddc02.gnilink.net>...
> Brian Berneker wrote:
> > File existence test is simple
> >
> > if (-e "filename") { whatever }
>
> Hmmm, sure, yes. Just like documented in perldoc -f -X.
> Is there anything special about it that surprises you or that you would like
> to discuss?
>
> jue
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5235
***************************************