[23404] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5622 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 6 09:05:56 2003

Date: Mon, 6 Oct 2003 06: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           Mon, 6 Oct 2003     Volume: 10 Number: 5622

Today's topics:
    Re: code with style (Anno Siegel)
        EBCDIC-ASCII Conversation <r.burgmann@gmx.net>
    Re: EBCDIC-ASCII Conversation <lambik@kieffer.nl>
    Re: improve the efficiency <tore@aursand.no>
    Re: improve the efficiency <REMOVEsdnCAPS@comcast.net>
    Re: improve the efficiency <ebohlman@earthlink.net>
    Re: Order of evaluation of expressions (David Combs)
    Re: Order of evaluation of expressions (David Combs)
    Re: Pattern Match With $ (2) (Lack Mr G M)
    Re: Pattern Match With $ (Anno Siegel)
    Re: Pattern Match With $ <kuujinbo@hotmail.com>
    Re: regex with nots in it <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: regex with nots in it <usenet@bens-house.org.uk>
    Re: regex with nots in it <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: regex with nots in it (Anno Siegel)
    Re: regex with nots in it (Anno Siegel)
    Re: regex with nots in it <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: regex with nots in it <usenet@bens-house.org.uk>
    Re: two regexs (Greg Bacon)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 6 Oct 2003 12:44:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: code with style
Message-Id: <blro43$73b$1@mamenchi.zrz.TU-Berlin.DE>

Pedro <pedro.fabre.NO-SPAM@gen.gu.se> wrote in comp.lang.perl.misc:
> Hi all,
> 
> I was trying to calculate the max number of variations of the columns on
> an array.
> 
> I have worked the code on this way. It works fine and I get what I need
> but I think that still my style is not too perl.
> 
> The idea is that I have to take the length of the array in order to
> operate by columns and then go for every element of the row.
> 
> 
> I am not fully convinced with my style, and I guess this can be done in a
> simpler way.
> 
> Any suggestion?
> 
> 
> Thanks for your help
> P
> 
> 
> use strict;
> 
> my @a = (
>          [qw/1 2 3 4 5/],
>          [qw/2 2 3 2 4/],
>          [qw/3 1 2 4 5/]
>      );
> 
> my $var = maximum_multiplicity(\@a);
> 
> print "$var\n";

We have seen a few solutions using a hash to count the unique elements
in each array.  Here is how I would write it:

    sub maximum_multiplicity {
        my $max = 0;
        for ( @{shift() } ) {
            my %h;
            @h{ @$_} = ();
            $max = keys %h if keys %h > $max;
        }
        $max;
    }

And here is how I would *not* write it:

    sub maximum_multiplicity {
        my @x;
        @x[ map scalar keys( %{ { map { $_ => 1} @$_}}), @{ shift()}] = ();
        $#x;
    }

:)

Anno


------------------------------

Date: Mon, 6 Oct 2003 12:57:18 +0200
From: "Reinhard Burgmann" <r.burgmann@gmx.net>
Subject: EBCDIC-ASCII Conversation
Message-Id: <3f814a95$0$18772$91cee783@newsreader02.highway.telekom.at>

Hello,

I have to convert a EBCDIC-File into an ASCII-Code in perl. Unfortunately
part's of the files are in packed format I have to do this in perl. I think
a solution with two arrays is possible but maybe somebody has a better idea?

Thanks in advance

Reinhard




------------------------------

Date: Mon, 6 Oct 2003 13:16:24 +0200
From: "Lambik69" <lambik@kieffer.nl>
Subject: Re: EBCDIC-ASCII Conversation
Message-Id: <blriu9$f5n7p$1@ID-146686.news.uni-berlin.de>

"Reinhard Burgmann" <r.burgmann@gmx.net> schreef in bericht
news:3f814a95$0$18772$91cee783@newsreader02.highway.telekom.at...
> Hello,
>
> I have to convert a EBCDIC-File into an ASCII-Code in perl. Unfortunately
> part's of the files are in packed format I have to do this in perl. I
think
> a solution with two arrays is possible but maybe somebody has a better
idea?

http://search.cpan.org/~cxl/Convert-EBCDIC-0.06/lib/Convert/EBCDIC.pm

>
> Thanks in advance
>
> Reinhard
>
>




------------------------------

Date: Mon, 06 Oct 2003 13:22:32 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: improve the efficiency
Message-Id: <pan.2003.10.06.08.33.52.887509@aursand.no>

On Mon, 06 Oct 2003 13:19:29 +0800, Johnson Lau wrote:
> #!/usr/bin/perl
> use strict;
> use DBI;
> my $dbh = DBI->connect("DBI:XBase:") or die $DBI::errstr;
> my $abc = $dbh->selectcol_arrayref("select NAME1 from table1");
> my $def = $dbh->prepare("delete from table2 where NAME2 = ?", {'MaxRows' => 1});
> foreach (@$abc) {
>         $lc->execute($_);
> }

Does this really take _two hours_ to finish?  I've never used FoxPro
actually, but I didn't think that it was so slow?  Doing the same in MySQL
would have taken just a few seconds, I guess.

You are completely sure that it's only this part of your script that takes
so long to execute?  There aren't anything else we should know about?  And
you've tried to print out some debugging info in that 'foreach' loop?


-- 
Tore Aursand <tore@aursand.no>


------------------------------

Date: Mon, 06 Oct 2003 06:59:39 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: improve the efficiency
Message-Id: <Xns940C511F59094sdn.comcast@206.127.4.25>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"Johnson Lau" <johnson@siukeung.com> wrote in
news:blqu12$heq$1@justice.itsc.cuhk.edu.hk: 

> I wrote a code to compare the NAME1 in table1 an NAME2 in table2. If a
> NAME2 equals to any one of NAME1, delete the record containing NAME2.
> Each of table1 and table2 is in Foxpro (*.dbf) format, containing
> around 6000 records and sorting according to NAME1 or NAME2. It takes
> me around 2 hours to finish the job. Is it possible to improve the
> efficiency? Thanks very much. 

The perl code seems reasonably efficient.  Perhaps you could improve the 
database selects, but you'll get a better response for that if you ask in a 
database newsgroup, I'll bet.

- -- 
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBP4FY4GPeouIeTNHoEQISzACg0GM9ilRlkUN4lBbMjVEheteDc5sAn0qC
A9QbuAw7S73xHKkx7Yc1VTau
=j0A/
-----END PGP SIGNATURE-----


------------------------------

Date: 6 Oct 2003 12:13:45 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: improve the efficiency
Message-Id: <Xns940C4AFC4C4C8ebohlmanomsdevcom@130.133.1.4>

Tore Aursand <tore@aursand.no> wrote in
news:pan.2003.10.06.08.33.52.887509@aursand.no: 

> On Mon, 06 Oct 2003 13:19:29 +0800, Johnson Lau wrote:
>> #!/usr/bin/perl
>> use strict;
>> use DBI;
>> my $dbh = DBI->connect("DBI:XBase:") or die $DBI::errstr;
>> my $abc = $dbh->selectcol_arrayref("select NAME1 from table1");
>> my $def = $dbh->prepare("delete from table2 where NAME2 = ?",
>> {'MaxRows' => 1}); foreach (@$abc) {
>>         $lc->execute($_);
>> }
> 
> Does this really take _two hours_ to finish?  I've never used FoxPro
> actually, but I didn't think that it was so slow?  Doing the same in
> MySQL would have taken just a few seconds, I guess.

FoxPro doesn't really have native SQL support; DBD::XBase is providing it 
through flat-file operations.  It's not actually using an optimized 
database engine.

If table2 isn't indexed (or DBD::XBase can't take advantage of an index) 
then the algorithm reduces to a linear search of table2 for each entry in 
table1, giving quadratic behavior.  In that case, short of switching to a 
true database engine, the OP would be best off reading in all the entries 
in both tables, using standard hash methods to find their intersection, and 
then doing deletes on only those keys in the intersection.


------------------------------

Date: Mon, 6 Oct 2003 12:18:33 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Order of evaluation of expressions
Message-Id: <blrmip$l5b$1@reader2.panix.com>

In article <Xns93FC661F95B86sdn.comcast@206.127.4.25>,
Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
>dkcombs@panix.com (David Combs) wrote in news:bkdtkp$2j8$1
>@reader2.panix.com:
>
>> In article <Xns93EEEC3E82233sdn.comcast@206.127.4.25>,
>> Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
>> ...
>> 
>> 
>> What I believe to be true is that when dealing
>> with *reals*, addition doesn't necessarily
>> commute, ie a + b doesn't necessairly equal b + a,
>> because of the limited precision of reals.
>
>Offhand, I can't think of an example where this would be true.  Can you 
>give an example?

Nope -- Ilya corrected "commute" to "associate".

d.



------------------------------

Date: Mon, 6 Oct 2003 12:23:32 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Order of evaluation of expressions
Message-Id: <blrms4$l84$1@reader2.panix.com>

In article <slrnbll4v7.3cm.sholden@staff.cs.usyd.edu.au>,
Sam Holden  <sholden@cs.usyd.edu.au> wrote:
>On Sun, 7 Sep 2003 01:36:35 +0000 (UTC), David Combs <dkcombs@panix.com> wrote:
>
>[snip order or evaluation and precendence being different]
>
>> 
>> THERE IT IS AGAIN, THAT STATEMENT! (this time not referring to C, though)
>> 
>> If true, I guess that in perl you cannot add up wildly-differently-sized
>> reals (er, numbers) (where you know which are big and which are small).
>> 
>> What, have to write separate assignment statements, each one
>> growing by the next one of a, b, c, d, etc, being thus forced
>> to recode the only *intuitively* numerical-analysisly-correct:
>> 
>> z  =  (a + (b + (c + (d + (e + (f))))))
>
>Associativity and prededence have almost *nothing* to do with order of
>evaluation. The order of evaluation in that example is irrelevant (assuming
>those letters represent single numeric values.
>
>Order of evaluation comes in, when you do something like:
>
>z = (a() + ((b() + (c() + (d() + (e() + (f())))))))
>
>The result will be as expected, in that e() + f() will be calculated, and then
>d() + <prior result> and so on and so on. 
>
>Order of evaluation defined the order in which the functions a(), b(), .. f()
>will be called. 
>
>They could be called as they are needed, in which case e() and f() will be
>called first, then d(), then c(), then b(), then a(). Or they all be called
>before the calculation begins arbitrary order. Or some micture of the two.
>
>Order of evaluation only matters when those function have side effect, or
>when when things like a++ are used, which also have side effects.
>
>So in the perl example from above with some modification to make the
>side effects of the shift function matter:
>
>*a = *b = *c = *c; #make the side effects matter...
>@a = qw/a b c d/;
>$first = (shift(@a) . (shift(@b)  . (shift(@c)  . shift(@d))));
>
>@a = qw/a b c d/;
>$second = shift(@c)  . shift(@d);
>$second = shift(@b) . $second;
>$second = shift(@a) . $second;
>print "first: $first; second: $second\n";
>
>Both $first and $second use the same associativity and precedence. However,
>they have different order of evaluations.
>
>From the output I get perl is evaluating the shift()s from left to right,
>even though the parenthesis mean it is calculating the result from right
>to left.
>
>The calculation will be done in the order indicated by the precendence
>and parenthesis. However, the evaluation of the individual terms is done
>in a different (possibly arbitrary or random) order. The evaluation of
>individual terms can *not* affect the result, unless there are
>*side effects*.

So few understand what I (probably badly) said, although
Ilya did.  It's to do with the limited precision of
reals, on computers. 

Perhaps Ilya's post makes everything clear.

David



------------------------------

Date: Mon, 06 Oct 2003 11:28:00 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: Pattern Match With $ (2)
Message-Id: <2003Oct6.112800@ukwit01>

In article <4d2111c5.0310060203.3da86a45@posting.google.com>, yccheok@yahoo.com (Cheok Yan Cheng) writes:
|>
|> i expect both are match. but i got the result:
|>...
|> how can i solve this problem?

> $ebb = '$ebb';
> if($ebb =~ /${ebb}/)

   This replaces ${ebb} with it's value and ends up doing:

if ($ebb =~ /$ebb/)

   Now, since variable interpolation has already been done the '$' here
means end-of-line.  So the match fails.

   You can "see" what is happenign if you add:

 use re 'debug';

to the start of the script.

   The cure is to use:

 if ($ebb =~ /\Q${ebb}/)

if you want all of characaters in ${ebb} to be treated literally.  Of
course, if the contents may be a regular expression then you have to
take care when setting it up instead. 


-- 
--------- Gordon Lack --------------- gml4410@ggr.co.uk  ------------
This message *may* reflect my personal opinion.  It is *not* intended
to reflect those of my employer, or anyone else.


------------------------------

Date: 6 Oct 2003 10:27:11 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Pattern Match With $
Message-Id: <blrg1v$q$2@mamenchi.zrz.TU-Berlin.DE>

Cheok Yan Cheng <yccheok@yahoo.com> wrote in comp.lang.perl.misc:
> i have a file named 'list' with content:
> --------------------------------------------------------------------------------
> $ebb.runrv_out
> $ebb.emsh_log
> rv/$ebb.rv.audit
> $ebb.notexist
> --------------------------------------------------------------------------------
> i try the following code:
> 
> #!/usr/intel/bin/perl

No warnings, no strictures.  Bad.

> 
> $ebb = '$ebb';

There is no reason why $ebb should be a package variable.  Declare it
with "my".

> open(LIST, "list") || die "$!\n";
> while(<LIST>)
> {
>         print;
>         print " is going match with $ebb\n";
> 
>         if(/^${ebb}(\.)/)

There is no reason for the "{}" around "ebb".  If you want a literal "$"
in a regex, escape it with "\":

          if ( /^\$ebb(\.)/ )

Note that this regex doe *not* refer to the variable "$ebb", it contains
a literal "$", literally followed by "ebb".

If you *must* keep that part in a variable, use the "\Q" and "\E" escapes
to protect the "$":

          if( /^\Q$ebb\E(\.)/ )

>         {
>                 print "YEAH!\n";
>         }
>         else
>         {
>                 print "NO!\n";
>         }
> }
> close(LIST);
> 
> 
> the output i get is 
> --------------------------------------------------------------------------------
> $ebb.runrv_out
>  is going match with 
> NO!

[...]

This is not the output of your program.  The second line ought to be
" is going match with $ebb".  Please take care in preparing your post,
so the reader doesn't have to resolve contradictions.

Anno



------------------------------

Date: Mon, 06 Oct 2003 20:34:10 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Pattern Match With $
Message-Id: <blrk3a$dfr$1@pin3.tky.plala.or.jp>

Cheok Yan Cheng wrote:

[snip]

> i expect to get "YEAH" frm pattern
> 
> if(/^${ebb}(\.)/)
> 
> but it failed :( may i noe how can i solve this prob?

There are some characters that you cannot use literally in a regular 
expression, one of them is '$'. These special characters are called 
metacharacters. You always have to 'escape' the metacharacter either, as 
Anno pointed out with \Q ... \E ($ebb is being interpolated ), or with a 
backslash when you want to match the literal character itself. The list 
of metacharacters (from perlretut) is:

	{}[]()^$.|*+?\

Reading perlretut and perlre will give you more detail on using regular 
expressions.

HTH  -keith



------------------------------

Date: Mon, 6 Oct 2003 10:13:47 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: regex with nots in it
Message-Id: <Xns940C7C3FA4DADelhber1lidotechnet@62.89.127.66>

"Ben Holness" <usenet@bens-house.org.uk> wrote in
news:pan.2003.10.06.08.58.11.731075@bens-house.org.uk: 

> Hi all,
> 
> I would like to know if it is possible to have nots in a single
> regular expression and if so, how to do it?
> 
> For example if I want a single regular expression that says:
> 
> The phrase must have the string "Perl" and must not be followed by
> "PHP" in it, so that it would match:
> 
> "I like Perl"
> "Perl is cool"
> 
> But not match
> 
> "I like Perl more than PHP"
> "Although PHP is OK"
>
> I haven't been able to work out how to do it, but if '!' were the not
> operator, then I guess it would be something like
> 
> /Perl.*![PHP]/
> 
> Searching hasn't been much help - the word "not" is way too common :)


Then look for "look-ahead" in perlre.pod.


Cheers,
Bernard


------------------------------

Date: Mon, 06 Oct 2003 12:07:13 +0100
From: "Ben Holness" <usenet@bens-house.org.uk>
Subject: Re: regex with nots in it
Message-Id: <pan.2003.10.06.11.07.13.474914@bens-house.org.uk>


>> The phrase must have the string "Perl" and must not be followed by
>> "PHP" in it, so that it would match:
>> 
>> "I like Perl"
>> "Perl is cool"
>> 
>> But not match
>> 
>> "I like Perl more than PHP"
>> "Although PHP is OK"
>
> Then look for "look-ahead" in perlre.pod.

hmmm. Doesn't seem to work because look-ahead cannot deal with wildcards:

/Perl.*(?!PHP)/

doesn't do what I want :( perlre suggests that it's easier to have it as
two regular expressions, which is what I was trying to avoid.

Any other ideas?

Cheers anyway,

Ben


------------------------------

Date: Mon, 6 Oct 2003 11:26:53 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: regex with nots in it
Message-Id: <Xns940C88A4CC84Aelhber1lidotechnet@62.89.127.66>

"Ben Holness" <usenet@bens-house.org.uk> wrote in 
news:pan.2003.10.06.11.07.13.474914@bens-house.org.uk:

> 
>>> The phrase must have the string "Perl" and must not be followed by
>>> "PHP" in it, so that it would match:
>>> 
>>> "I like Perl"
>>> "Perl is cool"
>>> 
>>> But not match
>>> 
>>> "I like Perl more than PHP"
>>> "Although PHP is OK"
>>
>> Then look for "look-ahead" in perlre.pod.
> 
> hmmm. Doesn't seem to work because look-ahead cannot deal with wildcards:
> 
> /Perl.*(?!PHP)/


Try


  /Perl(?!.*PHP)/


> doesn't do what I want :( perlre suggests that it's easier to have it as
> two regular expressions, which is what I was trying to avoid.


Why? It's a perfectly valid suggestion.


Cheers,
Bernard


------------------------------

Date: 6 Oct 2003 11:35:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regex with nots in it
Message-Id: <blrk1p$31f$1@mamenchi.zrz.TU-Berlin.DE>

Ben Holness <usenet@bens-house.org.uk> wrote in comp.lang.perl.misc:
> 
> >> The phrase must have the string "Perl" and must not be followed by
> >> "PHP" in it, so that it would match:
> >> 
> >> "I like Perl"
> >> "Perl is cool"
> >> 
> >> But not match
> >> 
> >> "I like Perl more than PHP"
> >> "Although PHP is OK"
> >
> > Then look for "look-ahead" in perlre.pod.
> 
> hmmm. Doesn't seem to work because look-ahead cannot deal with wildcards:
> 
> /Perl.*(?!PHP)/

No, your "wild cards" make short shrift with the look-ahead.  Even if
there is a "PHP" after "Perl", it is always possible for ".*" to match
enough of the following string to make any "PHP" disappear, so the
negative look-ahead succeeds (doesn't see PHP).  Take the ".*" into
the lookahead:

    /Perl(.*?!PHP)/

Anno


------------------------------

Date: 6 Oct 2003 11:51:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regex with nots in it
Message-Id: <blrl0k$3n0$1@mamenchi.zrz.TU-Berlin.DE>

Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in comp.lang.perl.misc:
> "Ben Holness" <usenet@bens-house.org.uk> wrote in 
> news:pan.2003.10.06.11.07.13.474914@bens-house.org.uk:
> 
> > 
> >>> The phrase must have the string "Perl" and must not be followed by
> >>> "PHP" in it, so that it would match:
> >>> 
> >>> "I like Perl"
> >>> "Perl is cool"
> >>> 
> >>> But not match
> >>> 
> >>> "I like Perl more than PHP"
> >>> "Although PHP is OK"
> >>
> >> Then look for "look-ahead" in perlre.pod.
> > 
> > hmmm. Doesn't seem to work because look-ahead cannot deal with wildcards:
> > 
> > /Perl.*(?!PHP)/
> 
> 
> Try
> 
> 
>   /Perl(?!.*PHP)/
> 
> 
> > doesn't do what I want :( perlre suggests that it's easier to have it as
> > two regular expressions, which is what I was trying to avoid.
> 
> 
> Why? It's a perfectly valid suggestion.

The condition that "PHP" must come after "Perl" makes the two-regex
solution a little less attractive.  Some trickery with pos() or
@+ is required, as in

    /Perl/g && !/\G.*PHP/

which makes it slightly obscure.

Anno


------------------------------

Date: Mon, 6 Oct 2003 12:14:05 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: regex with nots in it
Message-Id: <Xns940C90A5E4988elhber1lidotechnet@62.89.127.66>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in
news:blrl0k$3n0$1@mamenchi.zrz.TU-Berlin.DE: 

> Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net> wrote in
> comp.lang.perl.misc: 
>> "Ben Holness" <usenet@bens-house.org.uk> wrote in 
>> news:pan.2003.10.06.11.07.13.474914@bens-house.org.uk:
>> 
>> > 
>> >>> The phrase must have the string "Perl" and must not be followed
>> >>> by "PHP" in it, so that it would match:
>> >>> 
>> >>> "I like Perl"
>> >>> "Perl is cool"
>> >>> 
>> >>> But not match
>> >>> 
>> >>> "I like Perl more than PHP"
>> >>> "Although PHP is OK"
>> >>
>> >> Then look for "look-ahead" in perlre.pod.
>> > 
>> > hmmm. Doesn't seem to work because look-ahead cannot deal with
>> > wildcards: 
>> > 
>> > /Perl.*(?!PHP)/
>> 
>> 
>> Try
>> 
>> 
>>   /Perl(?!.*PHP)/
>> 
>> 
>> > doesn't do what I want :( perlre suggests that it's easier to have
>> > it as two regular expressions, which is what I was trying to avoid.
>> 
>> 
>> Why? It's a perfectly valid suggestion.
> 
> The condition that "PHP" must come after "Perl" makes the two-regex
> solution a little less attractive.


Quite correct. I somehow forgot about that requirement even though it
was the point of the OP in the first place. :-)


> Some trickery with pos() or @+ is required, as in
> 
>     /Perl/g && !/\G.*PHP/
> 
> which makes it slightly obscure.


"Butt ugly" seems a more appropriate description. ;-)


Very imaginative, though. :-)


Cheers,
Bernard


------------------------------

Date: Mon, 06 Oct 2003 13:40:28 +0100
From: "Ben Holness" <usenet@bens-house.org.uk>
Subject: Re: regex with nots in it
Message-Id: <pan.2003.10.06.12.40.28.822039@bens-house.org.uk>


>> doesn't do what I want :( perlre suggests that it's easier to have it as
>> two regular expressions, which is what I was trying to avoid.
> 
> 
> Why? It's a perfectly valid suggestion.

The system I have built checks messages for particular content. The
content is defined in a database, so if I need more than one regex, I need
to implement some slightly more clever code than just getting the regex
from the db and matching :)

The suggestions from yourself and Anno are what I needed though;

/Perl(?!.*PHP)/ does exactly what I need :)

Thanks,

Ben


------------------------------

Date: Mon, 06 Oct 2003 12:49:00 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: two regexs
Message-Id: <vo2p5s5pfhsq1d@corp.supernews.com>

In article <6n60ov407q1d0ut9hg0mohfjdqj000jivc@4ax.com>,
    Matija Papec  <perl@my-header.org> wrote:

: It's fine but I was thinking about /alternative/ method for "match
: everything between quotes OR match all consecutive non white chars". Since I
: need this to parse html forms, I ended up with,
: 
:   my $atr = qr/(?:["'](.*?)["']|([^>\s]+))/;
: 
: And here is the reinvented wheel with some known limitations(it doesn't
: support group of checkboxes with same names).

Is there a reason you're not using CGI.pm or another CGI module
from the CPAN that doesn't have this limitation?

Greg
-- 
Democracy is two wolves and a lamb voting on what to have for lunch.
Liberty is a well-armed lamb contesting the vote.
    -- Ben Franklin


------------------------------

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



------------------------------

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 5622
***************************************


home help back first fref pref prev next nref lref last post