[19698] in Perl-Users-Digest
Perl-Users Digest, Issue: 1893 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 8 21:07:04 2001
Date: Mon, 8 Oct 2001 18:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002589506-v10-i1893@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 8 Oct 2001 Volume: 10 Number: 1893
Today's topics:
Re: Another time source then the server time (David Efflandt)
Re: Filename case... <novastar@novastar.dtdns.net>
Re: How to run perl under bash not sh (Abigail)
Re: How to run perl under bash not sh <tintin@snowy.calculus>
Re: How to run perl under bash not sh <invalid@nowhere.com>
Re: How to run perl under bash not sh <invalid@nowhere.com>
Re: How to run perl under bash not sh <tony_curtis32@yahoo.com>
HTML Template Parsing Problem <mike@mikemackay.co.uk>
Illegal Instruction - out of the blue <clarkvent@hotmail.com>
Re: Need help - pragmatic modules not available <mjcarman@home.com>
Re: Obfuscation <aw_eis@compuserve.com>
Re: pattern matching (Tony)
Re: programmers/partners wanted in NJ/NY/PA/CT <dha@panix.com>
Re: unix comm perl style <vbrammer@home.com>
Re: use strict my $foo = ""; Bug? <comdog@panix.com>
Re: use strict my $foo = ""; Bug? (Abigail)
Re: use strict my $foo = ""; Bug? (Greg Bacon)
Re: What good is "\G" in a regular expression? <joe+usenet@sunstarsys.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Oct 2001 00:53:05 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Another time source then the server time
Message-Id: <slrn9s4ijh.ka9.efflandt@typhoon.xnet.com>
On Mon, 8 Oct 2001 23:13:55 +0800, Bas Voordendag <basv@ozemail.com.au> wrote:
> Is there another time source then the server time?
> I need a time other then server time, can this with Perl?
> If so, how?
If you just want a different timezone, you can usually set the $ENV{TZ}
variable if your system supports it. For example if am in US Central time
(CST6CDT) and I set TZ to US Pacific time, perl displays that time for
localtime:
#!/usr/bin/perl -w
use POSIX;
my $date = POSIX::strftime("%c",localtime);
print "$date\n";
$ENV{TZ} = 'PST8PDT';
$date = POSIX::strftime("%c",localtime);
print "$date\n";
output:
Mon 08 Oct 2001 07:51:36 PM CDT
Mon 08 Oct 2001 05:51:36 PM PDT
--
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 9 Oct 2001 01:16:28 +0200
From: "novastar" <novastar@novastar.dtdns.net>
Subject: Re: Filename case...
Message-Id: <9pt8j7$fr$1@usenet.otenet.gr>
its all yours Brian !
my $directory="f:/work";
opendir(dir,$directory) || warn "Oh noooo ... $!\n";
foreach ( sort ( grep ( /^[^\.]+/ , readdir(dir) ) ) )
{
next if -d $_;
chomp;
if ( ! /[A-Z]/ ) {
print "file $_ is already in lowercase\n" ; next ; }
print "lets lowercase the file $_\n";
rename "$directory/$_" , $directory."/".eval{ tr/[A-Z]/[a-z]/; $_ };
}
close dir;
"Brian Racer" <brian@brianracer.com> wrote in message
news:7now7.87578$ME2.13936841@typhoon.kc.rr.com...
> What I need to do is in certain directories(unix), change every filename
> that has any upper-case letters to a filename with only lower-case
> charactors. I am somewhat new to perl (would perl even be the best tool
for
> this?) and I just have no idea how to go about doing this. Any help will
be
> greatly appreciated!!!
>
> Brian Racer
> brian@brianracer.com
>
>
------------------------------
Date: 8 Oct 2001 22:09:33 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How to run perl under bash not sh
Message-Id: <slrn9s490d.pns.abigail@alexandra.xs4all.nl>
Larry Alkoff (invalid@nowhere.com) wrote on MMCMLX September MCMXCIII in
<URL:news:i713st0d9r35vabqsbg3cmu233fassggi7@4ax.com>:
^^ I have a small perl script that "paginates" output from any program
^^ that would scroll output off the screen. It's called "so" for "scrolled
^^ output"/.
^^
^^ However, many of my programs are aliased and my perl script complains.
^^ For example dir is aliased and the command "so dir" gives the error message
^^ "sh: dir: command not found.
^^
^^ Apparently perl starts up under sh. How can I get it to start under bash so
^^ perl can use my aliases?
Huh? The Bourne shell doesn't have aliases.
Abigail
--
perl -we '$| = 1; $_ = "Just another Perl Hacker\n"; print
substr $_ => 0, 1 => "" while $_ && sleep 1 => 1'
------------------------------
Date: Tue, 9 Oct 2001 08:19:56 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: How to run perl under bash not sh
Message-Id: <rFpw7.13$ro1.2360472@news.interact.net.au>
"Abigail" <abigail@foad.org> wrote in message
news:slrn9s490d.pns.abigail@alexandra.xs4all.nl...
> Larry Alkoff (invalid@nowhere.com) wrote on MMCMLX September MCMXCIII in
> <URL:news:i713st0d9r35vabqsbg3cmu233fassggi7@4ax.com>:
> ^^ I have a small perl script that "paginates" output from any program
> ^^ that would scroll output off the screen. It's called "so" for
"scrolled
> ^^ output"/.
> ^^
> ^^ However, many of my programs are aliased and my perl script complains.
> ^^ For example dir is aliased and the command "so dir" gives the error
message
> ^^ "sh: dir: command not found.
> ^^
> ^^ Apparently perl starts up under sh. How can I get it to start under
bash so
> ^^ perl can use my aliases?
>
>
> Huh? The Bourne shell doesn't have aliases.
The OP's just another Linux user who doesn't realise /bin/sh is a link to
/bin/bash
------------------------------
Date: Mon, 08 Oct 2001 23:08:20 GMT
From: Larry Alkoff <invalid@nowhere.com>
Subject: Re: How to run perl under bash not sh
Message-Id: <i6b4stob2fi95qr2k38qrmg1lknp2ietc4@4ax.com>
"Tintin" <tintin@snowy.calculus> wrote:
> > Huh? The Bourne shell doesn't have aliases.
The bash shell certainly does and that's what I mostly use.
> The OP's just another Linux user who doesn't realise /bin/sh is a link to
> /bin/bash
By george I just checked /bin and so it is only a link to bash!
But there must be _some_ reason why I get sh: error messages
when I use perl -w. And perl itself has paths to sh and csh.
And why perl can't find/use any of my aliases?
I mystified because I can't find any evidence of the sh executable
on my system using
locate bin/sh
Locate sh produced something like 20k lines of output!
Larry
--
Larry Alkoff N2LA
My address is: larryalk is_at mindspring dot com
------------------------------
Date: Mon, 08 Oct 2001 23:20:32 GMT
From: Larry Alkoff <invalid@nowhere.com>
Subject: Re: How to run perl under bash not sh
Message-Id: <v9c4st4092nqp0nsij3c8p6ct59bnfrcgk@4ax.com>
>
> The OP's just another Linux user who doesn't realise /bin/sh is a link to
> /bin/bash
To follow up on my last post, I did some testing.
In my normal shell I type
alias or al (my alias for alias)
and get alist of my aliases.
I then type the command dkdkdk
and get a bash: dkdkdk: command not found error message.
I then type the command sh which should be loading bash
via the soft link in /bin. BTW, which shows /bin/sh - the soft link.
However ...
When I type
al
I get the error msg sh: al: command not found
When I type
alias
I draw a complete blank indicating that something knows about aliases
but there aren't any defined.
When I type my normal test command dkdkdk
I get the message
sh: dkdkdk: command not found.
Now I realize that this is a perl group but I find it very strange that
perl is somehow using a version of sh that I can't even find on my system.
Maybe it's built-in?
In any case my problem of how to use bash in my particular perl script
has been solved although I am awaiting some help on debugging it.
But there really should be an easy way in perl to ask it nicely to use
whatever shell I want.
Thanks All
Larry
--
Larry Alkoff N2LA
My address is: larryalk is_at mindspring dot com
------------------------------
Date: Mon, 08 Oct 2001 18:55:37 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How to run perl under bash not sh
Message-Id: <87u1x94rgm.fsf@limey.hpcc.uh.edu>
>> On Mon, 08 Oct 2001 23:20:32 GMT,
>> Larry Alkoff <invalid@nowhere.com> said:
> In my normal shell I type alias or al (my alias for
> alias) and get alist of my aliases.
> I then type the command dkdkdk and get a bash: dkdkdk:
> command not found error message.
> I then type the command sh which should be loading bash
> via the soft link in /bin. BTW, which shows /bin/sh -
> the soft link.
> However ...
> When I type al I get the error msg sh: al: command not
> found
Correct. sh does not have aliases. but bash does.
> When I type alias I draw a complete blank indicating
> that something knows about aliases but there aren't any
> defined.
This is probably because under linux, sh is actually bash
pretending to be "dumb". Presumably it is accepting
"alias" as a command because it's really bash, but won't
let you actually define anything, because it's pretending
to be a Bourne shell.
> When I type my normal test command dkdkdk I get the
> message sh: dkdkdk: command not found.
That's right, there are no aliases in sh, nor is there a
standard command called "dkdkdk" (and there isn't one on
your path either).
> Now I realize that this is a perl group but I find it
> very strange that perl is somehow using a version of sh
> that I can't even find on my system. Maybe it's
> built-in?
It's using /bin/sh.
> In any case my problem of how to use bash in my
> particular perl script has been solved although I am
> awaiting some help on debugging it. But there really
> should be an easy way in perl to ask it nicely to use
> whatever shell I want.
Already demonstrated:
system '/bin/bash', '-c', ...
(if there are no shell meta-characters in a scalar
argument to system() then no interpreter is involved.
Unless you run your own like this with the LIST syntax).
hth
t
--
Whoops, I've said too much. Smithers, use the amnesia ray...
------------------------------
Date: Mon, 08 Oct 2001 21:31:48 GMT
From: "Mike Mackay" <mike@mikemackay.co.uk>
Subject: HTML Template Parsing Problem
Message-Id: <8Xow7.31303$II.2081182@news1.cableinet.net>
Hi,
I've written a basic search script that searches a given text file for
the string you tell it to. I am them using an html template to output the
search return to.
My script reads in the html file and where it finds <--search_result> the
script replaces it with its results. It all works fine until I get more than
one result from the search, then the script only prints the first match it's
come across and none of the other results........Can any shed any light on
this as the more I think about it the more I get confused....
Posted below is the main search routine with the basic template system built
in. I know the code may seem a bit messy but its just while I work on
this....
######################################################################
sub search {
open(TEMPLATE, $template_file);
while(<TEMPLATE>){
$buffer .= $_;
}
open (DATA, $data_file) || print "Error - $!";
$matches = 0;
while (<DATA>){
$result = $_;
chomp $result;
if (/$search/i){
$matches++;
foreach $item ($result){
($name,$url,$description) = split(/\|/,
$item);
$items="$matches. <a
href=$url>$name</a><br>$description<br>$url<br>";
}
}
}
$buffer =~ s/<--matches-->/$matches/g;
close(DATA);
}
######################################################################
$buffer =~ s/<--search_term-->/$search/g;
print $buffer;
exit();
------------------------------
Date: Mon, 08 Oct 2001 23:31:56 GMT
From: DrC <clarkvent@hotmail.com>
Subject: Illegal Instruction - out of the blue
Message-Id: <3BC23771.9696D155@hotmail.com>
I'm sorry if this has been asked before, but most of my websites are
down at the moment because of this error and I'm a bit desperate trying
to find the answer quick.
All of a sudden - out of the blue - all my Perl scripts are generating
an "Illegal Instruction" error (or "Internal Server Error" in a
browser). Nothing has changed to the server, and everything was working
perfectly up until an hour ago.
Perl version: 5.005
Linux version: 2.2.16
I have no clue where to look. Anybody want to give me a few tips?
Thanks.
------------------------------
Date: Mon, 08 Oct 2001 15:40:22 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Need help - pragmatic modules not available
Message-Id: <3BC20F36.2EB824B9@home.com>
RoJo wrote:
>
> I registered a domain name, bought the entry-level web hosting
> package at Mindspring (now Earthlink), and bought O'Reilly's
> Programming Perl, all so I could learn Perl.
The book was a good investment. The rest was unnecessary. Why didn't you
just download the distribution of Perl for whatever type of computer you
have?
> It's been going very well, by the way, with occasional help from
> you guys in this newsgroup. But I'm on a shoestring budget.
And you bought a domain name to learn Perl?!
> Per Mindspring tech sup, I am using v5.004_04 of Larry Wall's Perl
> on their web server, but to my surprise, the pragmatic modules are
> not available! (or at least not installed) Now that I've done the
> research to find out who Larry Wall is (the daddy of Perl !!), I
> am dumbfounded why a version he released would not include the
> pragma.
Yes, we know who Larry is. "He" doesn't release Perl anymore. It is now
a group effort. Larry's still involved, of course, but it's no longer a
one-man task. At any rate, no such version was ever released. Either you
are mistaken, or Mindspring has a badly broken installation.
> I need the pragma because I do not have telnet access and cannot
> run scripts (like a compile).
My fleeble has a tololu glabby nixfo.
In other words, that makes no sense. You need which pragma? There are
many. What do pragmas have to do with telnet access? If you can't run
scripts then what's the point in writing them? And just what do you mean
by "compile?"
> When I have a syntax error, the browser just says "The page
> cannot be displayed".
use PSI::ESP;
Okay, so you're writing CGI scripts. That's what I'd expect the browser
to say when you have a syntax error.
> Thankfully, so far, I've eventually figured them out via ActivePerl
> which I'm running on my Windows 2000 Professional workstation and
> calls to Mindspring tech sup.
So you do have Perl on your own PC. Then why did you think you needed to
purchase an account with Mindspring? You can get a free webserver to run
on your own PC, and if you're using CGI.pm (if you're just learning you
definately should be) it has an "offline" mode for testing. Even if you
did neither, you could still use your local install to catch syntax
errors:
perl -cw myscript.pl
Or, for a pseudo version of "lint" for Perl:
perl -Mstrict -Mdiagnostics -cw myscript.pl
> Aside of the compiler aids,
What compiler aids? You aren't trying to generate an executable, are
you?
> I'd like the assistance of "use lib" in subroutine communication.
The 'lib' pragma has nothing to do with "subroutine communication"
(whatever that is).
> Since that's not available,
How is it not available? Did
use lib '/path/to/my/library';
not add the directory to @INC? Did a subsequent 'use Foo::Bar;' not
find the module?
> Are the pragmatic modules for version 5.004_04 available for
> download,
No, they are installed as a part of Perl.
-mjc
------------------------------
Date: Tue, 09 Oct 2001 02:28:23 +0200
From: Andre Warnier <aw_eis@compuserve.com>
Subject: Re: Obfuscation
Message-Id: <3BC244A7.5E089D31@compuserve.com>
As a matter of fact, I just read something about that in the "scripts" page on
CPAN I believe.
Tim from AZ wrote:
> Does anyone know of a decent program that I could use to make my perl code
> harder to decifer?
------------------------------
Date: 8 Oct 2001 17:19:43 -0700
From: tadermann@hotmail.com (Tony)
Subject: Re: pattern matching
Message-Id: <6db8eeaf.0110081619.559e6c32@posting.google.com>
rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote in message news:<slrn9s2k4f.79d.rgarciasuarez@rafael.kazibao.net>...
> Alternatively you can use \b in your regexp. This matches a word
> boundary (see the perlre section of the docs) :
>
> if ($memberList =~ /\b$LoginId\b/) {...}
>
> Also, it's a good habit to protect the regexp against funny characters
> (e.g. if $LoginId contains a '*') :
>
> if ($memberList =~ /\b\Q$LoginId\E\b/) {...}
Thank you for the input, this achieved the desired result.
Thanks,
Tony
------------------------------
Date: 8 Oct 2001 22:27:34 GMT
From: "David H. Adler" <dha@panix.com>
Subject: Re: programmers/partners wanted in NJ/NY/PA/CT
Message-Id: <slrn9s4a2m.ebu.dha@panix2.panix.com>
In article <3BBD366E.A8CA159F@monmouth.com>, Richard Trahan wrote:
> I am a just-retired programmer in Monmouth County, NJ. I would like
> to network with experienced programmers in NJ/NY/PA/CT for the purpose
> of starting a porting business.
You have posted a job posting or a resume in a technical group.
Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.
Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :) (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).
Please do not explain your posting by saying "but I saw other job
postings here". Just because one person jumps off a bridge, doesn't
mean everyone does. Those postings are also in error, and I've
probably already notified them as well.
If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.
http://jobs.perl.org may be of more use to you
Yours for a better usenet,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I didn't say I'd never slay another vampire. It's not like I have
fluffy bunny feelings about them. I'm just not going to get too
extra-curricular about it." - Buffy
------------------------------
Date: Mon, 08 Oct 2001 23:43:06 GMT
From: "vbrammer" <vbrammer@home.com>
Subject: Re: unix comm perl style
Message-Id: <eSqw7.132570$Xz1.17381526@news1.rdc1.md.home.com>
thanks, your tips worked out. What i wrote seemed to work fine for 2 files,
but your debug showed me otherwise :)
Vince
"Mark Jason Dominus" <mjd@plover.com> wrote in message
news:3bc155e8.6d70$c@news.op.net...
> In article <Aa3w7.129607$Xz1.15829310@news1.rdc1.md.home.com>,
> vbrammer <vbrammer@home.com> wrote:
> >Im trying to do with perl what the unix comm command can do.
>
> Code follows.
>
> >this is what i have, and it works :
>
> No way, man. Try @log = (1,2,3) and @post=(2,3). It should produce
> @diff=(1), but it produces (1,2,3) instead.
>
> >can this be written simpler? or quicker?
>
> Quicker, I couldn't say. It's really easy to write fast code that
> doesn't work.
>
> Simpler, definitely. For example, I found this deeply confusing:
>
> shift @post if ($true eq 1) || push @diff , $_;
>
> I might have written this:
>
> push @diff, $_ unless $true;
> shift @post;
>
> which does exactly the same thing. Although I don't know why you
> think you're doing it, it would be a simpler way toi do the same
> thing, whatever it is.
>
> If you want it to work, you might try something like this:
>
> while (@log && @post) {
> if ($log[0] lt $post[0]) { push @diff, shift @log }
> elsif ($log[0] gt $post[0]) { push @diff, shift @post }
> else { push @same, shift @post; shift
@log }
> }
> push @diff, @log, @post;
>
> If you want to be more like the real 'comm', use:
>
> while (@a && @b) {
> if ($a[0] lt $b[0]) { push @a_not_b, shift @a }
> elsif ($a[0] gt $b[0]) { push @b_not_a, shift @b }
> else { push @a_and_b, shift @a; shift @b }
> }
> push @a_not_b, @a;
> push @b_not_a, @b;
>
> Now you have three arrays, @a_not_b, @b_not_a, and @a_and_b, which
> correspond to columns 1, 2, and 3 of comm's output.
>
> --
> @P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub
p{
>
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^or
d
> ($p{$_})&6];$p{$_}=/
^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
> close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
rand(2)if/\S/;print
------------------------------
Date: Mon, 08 Oct 2001 18:15:09 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: use strict my $foo = ""; Bug?
Message-Id: <comdog-B6539E.18150908102001@news.panix.com>
In article <9pt0m2$k8i$1@yojo.cs.utexas.edu>, throop@cs.utexas.edu
(David R. Throop) wrote:
> In article <9nifpe$m68$02$1@news.t-online.com>,
> Steffen Müller <tsee@gmx.net> wrote:
> >"James Gilbert" <jgrg@sanger.ac.uk> schrieb im Newsbeitrag
> >news:3B9CB627.B1333E63@sanger.ac.uk...
> >> A new programmer who has just started working
> >> for me had this piece of code:
> >> use strict
> >>
> >> my $foo = "";
> I'm with James. It's a bug. Any undocumented aspect of a language
> that invites a very hard to track down unexpected behavior and doesn't
> issue a warning is a bug.
what's the unexpected behaviour though? it does what i expect
it to do, even if that was not the intent of the author.
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: 8 Oct 2001 23:25:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: use strict my $foo = ""; Bug?
Message-Id: <slrn9s4dfj.q4k.abigail@alexandra.xs4all.nl>
David R. Throop (throop@cs.utexas.edu) wrote on MMCMLX September MCMXCIII
in <URL:news:9pt0m2$k8i$1@yojo.cs.utexas.edu>:
"" In article <9nifpe$m68$02$1@news.t-online.com>,
"" Steffen Müller <tsee@gmx.net> wrote:
"" >"James Gilbert" <jgrg@sanger.ac.uk> schrieb im Newsbeitrag
"" >news:3B9CB627.B1333E63@sanger.ac.uk...
"" >>
"" >> A new programmer who has just started working
"" >> for me had this piece of code:
"" >>
"" >> use strict
"" >>
"" >> my $foo = "";
""
"" I'm with James. It's a bug. Any undocumented aspect of a language
"" that invites a very hard to track down unexpected behavior and doesn't
"" issue a warning is a bug.
The code above is equivalent to:
use strict (my $foo = "");
which is legal Perl. After all, you want to be able to pass arguments
"use Foo". And note that use strict *can* take arguments (normally, they
are 'refs', 'vars' and 'subs').
OTOH, (un)import of strict.pm could do some argument checking. I will
write a patch tomorrow and submit it to p5p for review. It may not be
accepted though.
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: Tue, 09 Oct 2001 00:27:38 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: use strict my $foo = ""; Bug?
Message-Id: <ts4h3qano8j5d2@corp.supernews.com>
In article <slrn9s4dfj.q4k.abigail@alexandra.xs4all.nl>,
Abigail <abigail@foad.org> wrote:
: [...]
: OTOH, (un)import of strict.pm could do some argument checking. I will
: write a patch tomorrow and submit it to p5p for review. It may not be
: accepted though.
This issue has come up several times on p5p:
<URL:http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg01230.html>
<URL:http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg01175.html>
Greg
--
Those who do not understand UNIX are condemned to reinvent it -- badly.
-- Henry Spencer
------------------------------
Date: 08 Oct 2001 18:17:45 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: What good is "\G" in a regular expression?
Message-Id: <m3d73xhj3q.fsf@mumonkan.sunstarsys.com>
> "PerlFAQ Server" <faq@denver.pm.org> wrote in message
> news:Fxbw7.1032$Owe.387419136@news.frii.net...
[...]
> > Usenet notation, (that is, with leading ">" characters), and you
> > want change each leading ">" into a corresponding ":". You could
> > do so in this way:
> >
> > s/^(>+)/':' x length($1)/gem;
> >
> > Or, using "\G", the much simpler (and faster):
> >
> > s/\G>/:/g;
> >
These two regexps are only accidentally related. If the FAQ is going to
advocate the latter one as a simpler and faster version, then IMO the
former should have the "m" option removed.
[...]
> > while (<>) {
> > chomp;
> > PARSER: {
> > m/ \G( \d+\b )/gcx && do { print "number: $1\n"; redo; };
> > m/ \G( \w+ )/gcx && do { print "word: $1\n"; redo; };
> > m/ \G( \s+ )/gcx && do { print "space: $1\n"; redo; };
> > m/ \G( [^\w\d]+ )/gcx && do { print "other: $1\n"; redo; };
> > }
> > }
"novastar" <novastar@novastar.dtdns.net> asks upside-downwardly
if that is the same as:
> while (<>){ chomp;
> print "number: $1\n" if /(\d+)\b/g;
> print "word: $1\n" if /(\w+)/g;
> print "space: $1\n" if /(\s+)/g;
> print "other: $1\n" if /([^\w\d]+)/g; }
No, this is not a suitable replacement. One obvious problem is that
it is missing a redo statement; another is that your regexps destroy
pos() upon failure.
--
Joe Schaefer
perl -wle '$,=" ";{ my @x;sub x {if(@_){push @x,@_; return sub{push @x,@_;@x}}
sub{push @x,@_;@x}}
} print x ("Just")->("another"), x -> ("perl","hacker,")'
------------------------------
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 1893
***************************************