[18396] in Perl-Users-Digest
Perl-Users Digest, Issue: 564 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Mar 25 18:10:40 2001
Date: Sun, 25 Mar 2001 15:10:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985561818-v10-i564@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 25 Mar 2001 Volume: 10 Number: 564
Today's topics:
Re: Regex question <goldbb2@earthlink.net>
Re: Regex question (Tad McClellan)
Re: Regex question (Abigail)
Re: Regex question <joe+usenet@sunstarsys.com>
Re: Regex question <rick.delaney@home.com>
Re: Regex question <uri@sysarch.com>
Re: require'ing OO modules on the fly - any danger? (Eric Bohlman)
Re: Running another perl script from a script? <goldbb2@earthlink.net>
Re: Running another perl script from a script? <sheryle@mediaone.net>
Re: Subroutine in separate files (Ben Okopnik)
Re: Why do "Learning Perl" Books Do This? A Subroutine <comdog@panix.com>
Re: Writing a script to install Perl modules automatica <comdog@panix.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 25 Mar 2001 19:27:28 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Regex question
Message-Id: <3ABE4765.981D6F57@earthlink.net>
Ave Wrigley wrote:
>
> Anyone know a neat regex for the follwing; capture from a string a
> substing which contains any given 2 (3,4, ...) words, in any order.
> Something along the lines of:
>
> $string =~ /(?=.*foo)(?=.*bar)(.*?)(?<=foo.*)(?<=bar.*)/;
>
> execpt that variable length lookbehind not implemented.
>
> Ave Wrigley <Ave.Wrigley@itn.co.uk>
return true if( /(.*)\b(foo|bar|baz)\b(.*)/ and "$1$3" ~= // );
In other words, match one word, remove it, match again.
--
The difference between theory and practice is that in theory, theory and
practice are identical, but in practice, they are not.
------------------------------
Date: Sun, 25 Mar 2001 14:08:49 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regex question
Message-Id: <slrn9bsgi1.10g.tadmc@tadmc26.august.net>
Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>Ave Wrigley wrote:
>>
>> substing which contains any given 2 (3,4, ...) words, in any order.
>return true if( /(.*)\b(foo|bar|baz)\b(.*)/ and "$1$3" ~= // );
^^
Please do not post pseudo code, post Real Perl Code.
When, exactly, were you expecting that second pattern match to fail?
There are no possible values for $1 and $3 such that the 2nd
match (sans syntax errors) can fail. Might as well say "and 1"
there instead, or even say nothing.
Maybe you meant one of these instead:
... and "$1$3" =~ /^$/
or
... and length "$1$3"
Even after "fixing" your code, I do not see how it answers the
question that was asked...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 25 Mar 2001 21:05:12 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Regex question
Message-Id: <slrn9bsnc8.ovi.abigail@tsathoggua.rlyeh.net>
Tad McClellan (tadmc@augustmail.com) wrote on MMDCCLXIII September
MCMXCIII in <URL:news:slrn9bsgi1.10g.tadmc@tadmc26.august.net>:
&& Benjamin Goldberg <goldbb2@earthlink.net> wrote:
&& >Ave Wrigley wrote:
&& >>
&& >> substing which contains any given 2 (3,4, ...) words, in any order.
&&
&& >return true if( /(.*)\b(foo|bar|baz)\b(.*)/ and "$1$3" ~= // );
&& ^^
&&
&& Please do not post pseudo code, post Real Perl Code.
&&
&& When, exactly, were you expecting that second pattern match to fail?
&&
&& There are no possible values for $1 and $3 such that the 2nd
&& match (sans syntax errors) can fail. Might as well say "and 1"
&& there instead, or even say nothing.
$ perl -nwle 'print /(.*)\b(foo|bar|baz)\b(.*)/ && "$1$3" =~ // ? "Yes" : "No"'
foo bar baz
Yes
foo
No
foo foo
Yes
foo bar arf foo
Yes
tarf foo tarf
No
tarf foo tarf bar
Yes
$
Abigail
--
my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
$qr =~ s/$qr//g;
print $qr, "\n";
------------------------------
Date: 25 Mar 2001 16:44:14 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Regex question
Message-Id: <m3snk1bk29.fsf@mumonkan.sunstarsys.com>
tadmc@augustmail.com (Tad McClellan) writes:
> Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> >Ave Wrigley wrote:
> >>
> >> substing which contains any given 2 (3,4, ...) words, in any order.
>
> >return true if( /(.*)\b(foo|bar|baz)\b(.*)/ and "$1$3" ~= // );
> ^^
>
> Please do not post pseudo code, post Real Perl Code.
>
> When, exactly, were you expecting that second pattern match to fail?
>
From camel v.2, p538 (Ch 8- section on Efficiency)
... For patterns that change occasionally, you can use the fact that
a null pattern refers back to the previous pattern, like this:
"foundstring" =~ /$currentpattern/; # Dummy match (must succeed).
while (<>) {
print if //;
}
...
The // magic is not a part of any standard documentation that I am
aware of, but if you have mod_perl installed, it is discussed in
% man mod_perl_traps
IMHO it is a loathesome "feature" of perl that is obsoleted by qr//.
--
Joe Schaefer "Anyone who considers arithmetical methods of producing random
digits is, of course, in a state of sin."
-- John von Neumann
------------------------------
Date: Sun, 25 Mar 2001 22:48:15 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Regex question
Message-Id: <3ABE78F1.EE395AD6@home.com>
Joe Schaefer wrote:
>
> The // magic is not a part of any standard documentation that I am
> aware of,
It is documented in the obvious place, perlop.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 25 Mar 2001 22:59:25 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Regex question
Message-Id: <x7wv9dzc8i.fsf@home.sysarch.com>
>>>>> "JS" == Joe Schaefer <joe+usenet@sunstarsys.com> writes:
JS> The // magic is not a part of any standard documentation that I am
JS> aware of, but if you have mod_perl installed, it is discussed in
you didn't look hard enough. it is not a regex feature but a m//
feature. so it is documented in perlop (5.005_03):
If the PATTERN evaluates to the empty string, the
last successfully matched regular expression is used
instead.
note that is says evaluates to an empty pattern which mean that
$p = '' ; /$p/ ;
will also have that behavior which some don't think should happen.
JS> IMHO it is a loathesome "feature" of perl that is obsoleted by qr//.
i agree. there might be some obscure reason to use it but you can do
whatever with qr// and be much clearer about it.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 25 Mar 2001 22:31:48 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: require'ing OO modules on the fly - any danger?
Message-Id: <99lrkk$9lu$1@bob.news.rcn.net>
Daniel Berger <djberg96@hotmail.com> wrote:
> I'll need to look up the difference between eval "something" vs eval{
> something }. I honestly don't know the difference off the top of my head.
> Bad programmer....
eval string is Perl's run-time compilation mechanism. eval block is
Perl's "try-catch" exception-handling mechanism.
------------------------------
Date: Sun, 25 Mar 2001 19:38:56 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Running another perl script from a script?
Message-Id: <3ABE4A16.E7284312@earthlink.net>
D.J. Poot wrote:
>
> Hi there,
>
> I have a perl script from which I need to call another perl script,
> and then return to the first one. (See below)
>
> ---Example---
>
> perlscript1.pl runs, prints some HTML...
> perlscript2.pl runs, prints some dynamic data...
> perlscript1.pl continues, finishes up the HTML and the scripts are
> both done...
>
> ---Example---
>
> I have been looking at the 'system()' call, but a simple "system
> '/perlscript2.pl';" doesn't seem to do anything, really. Therefore, I
> am asking you people now.. How can I run a perl script from another
> script?
>
> Thanks a lot in advance!
>
> Greetings,
> Dominique
Well, Gregory Toomey posted some possiblities, two others are: Does your
OS recognize that the perlscript2.pl file is a "runnable" file (ie, has
the executable flag set on unix, has an association set on Win), and, if
it is unix, does the file properly start with "#!/path/to/perl -w" ?
Perhaps you would be better of doing it as:
do "perlscript2.pl";
or perhaps:
eval { require "perlscript2.pl" };
or whatever.
--
The difference between theory and practice is that in theory, theory and
practice are identical, but in practice, they are not.
------------------------------
Date: Sun, 25 Mar 2001 20:11:14 GMT
From: Patrick Martin <sheryle@mediaone.net>
Subject: Re: Running another perl script from a script?
Message-Id: <3ABE5417.7319358@mediaone.net>
require "perlscript2.pl";
should be adequate. If it isn't, then you probably have an issue
with your search path.
- Pat
Benjamin Goldberg wrote:
>
> D.J. Poot wrote:
> >
> > Hi there,
> >
> > I have a perl script from which I need to call another perl script,
> > and then return to the first one. (See below)
> >
> > ---Example---
> >
> > perlscript1.pl runs, prints some HTML...
> > perlscript2.pl runs, prints some dynamic data...
> > perlscript1.pl continues, finishes up the HTML and the scripts are
> > both done...
> >
> > ---Example---
> >
> > I have been looking at the 'system()' call, but a simple "system
> > '/perlscript2.pl';" doesn't seem to do anything, really. Therefore, I
> > am asking you people now.. How can I run a perl script from another
> > script?
> >
> > Thanks a lot in advance!
> >
> > Greetings,
> > Dominique
>
> Well, Gregory Toomey posted some possiblities, two others are: Does your
> OS recognize that the perlscript2.pl file is a "runnable" file (ie, has
> the executable flag set on unix, has an association set on Win), and, if
> it is unix, does the file properly start with "#!/path/to/perl -w" ?
>
> Perhaps you would be better of doing it as:
> do "perlscript2.pl";
> or perhaps:
> eval { require "perlscript2.pl" };
> or whatever.
>
> --
> The difference between theory and practice is that in theory, theory and
> practice are identical, but in practice, they are not.
------------------------------
Date: 25 Mar 2001 21:29:31 GMT
From: ben-fuzzybear@geocities.com (Ben Okopnik)
Subject: Re: Subroutine in separate files
Message-Id: <slrn9bsp1m.ask.ben-fuzzybear@Odin.Thor>
The ancient archives of Sat, 17 Mar 2001 05:05:39 GMT showed
Uri Guttman of comp.lang.perl.misc speaking thus:
>>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
>
> G> Like I often say, DUH!
>
>yes, you say that all the time. you just spell it in computer gibberish.
>
>uri
<chuckle> Uri, I hope you don't mind ending up in my quote file...
Ben Okopnik
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
I've had a perfectly wonderful evening. But this wasn't it. -- Groucho Marx
------------------------------
Date: Sun, 25 Mar 2001 10:16:43 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: Why do "Learning Perl" Books Do This? A Subroutine Question.
Message-Id: <comdog-7D9ADD.10164325032001@news.panix.com>
In article <0gljbtkr4t93to6hkvpcpab758nkp026tn@4ax.com>, "Philip 'Yes,
that's my address' Newton" <nospam.newton@gmx.li> wrote:
> David Ehrens didn't mention the title "Learning Perl"
check the subject line. ;)
--
brian d foy <comdog@panix.com>
------------------------------
Date: Sun, 25 Mar 2001 10:25:44 -0600
From: brian d foy <comdog@panix.com>
Subject: Re: Writing a script to install Perl modules automatically
Message-Id: <comdog-B5115B.10254425032001@news.panix.com>
In article <99icj9$tvi$1@news6.svr.pol.co.uk>, "Makhno"
<imak@imakhno.freeserve.co.uk> wrote:
> Hi, I'm writing a bash script to install a large set of Perl modules
> automatically, and the trouble is that the Makefile.PL and all the other
> stuff that's needed to install them are at different levels, eg:
> I might have one module called MyModule
> and another called MyModule::Somefink::Else
> and yet another called MyModule::YetMore
what does your Makefile.PL file look like now? have you read
the docs for ExtUtils::MakeMaker?
--
brian d foy <comdog@panix.com>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 564
**************************************