Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

use re 'eval'

by faure (Sexton)
on Jul 21, 2001 at 21:47 UTC ( [id://98678]=perlquestion: print w/replies, xml ) Need Help??

faure has asked for the wisdom of the Perl Monks concerning the following question:

Q: Why isn't $1 set on the first pass?
#!/usr/bin/perl5.005 use strict; use re 'eval'; for (("a", "b", "c")) { m# (\w) (?{ print $1 }) #ox; print "\n---\n"; }
output:
--- b --- c ---
Any insight would be appreciated... (& you could save the life of a beautiful reg-ex!)

Replies are listed 'Best First'.
Re: use re 'eval'
by wine (Scribe) on Jul 21, 2001 at 23:19 UTC

    On CPAN the use of (?{}) is called "highly experimental"

    It works for perl 5.6 on both Linux and DEC/OSF, though. So, I guess it was a bug in the 5.005 release.

    I guess you have to upgrade or just have to go with the more simple and boring:

    use strict; for ("a","b","c") { print $_ . "\n---\n"; } # ;-)

    - Good luck

      (?{ thanks })
Re: use re 'eval'
by Dominus (Parson) on Jul 22, 2001 at 06:40 UTC
Re: use re 'eval'
by coolmichael (Deacon) on Jul 22, 2001 at 05:40 UTC
    I dunno. Sorry. I can tell you it works with ActiveState bulid 626 (Perl version 5.6.1)

    Michael

    update:
    It's broken with 5.005_03 built for i386-freebsd

    update again:keep reading. Dominus has the answer.

Re: use re 'eval'
by SparkeyG (Curate) on Jul 21, 2001 at 22:48 UTC
    As to why it won't work for you, I can't say; but it works on both perl 5.6.1 for cygwin and 5.6.0 on linux.

    May be a version problem.

    --SparkeyG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://98678]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-16 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found