lookaround

D

debraj

Hi All,

I am new to perl
and am wondering why the following is not running :

$_ = "The brown fox jumps over the lazy dog";
/the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
print "color = $color, animal = $animal\n";

its giving no output and if I use it in my programs it gives
Sequence (?{...) not recognized at.....

I took it from this link :

http://www.perldoc.com/perl5.8.0/pod/perlre.html

Thanx in advance,
Mark
 
A

Andras Malatinszky

debraj said:
Hi All,

I am new to perl
and am wondering why the following is not running :

$_ = "The brown fox jumps over the lazy dog";
/the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
print "color = $color, animal = $animal\n";

its giving no output and if I use it in my programs it gives
Sequence (?{...) not recognized at.....

I took it from this link :

http://www.perldoc.com/perl5.8.0/pod/perlre.html

Thanx in advance,
Mark
Just a few lines above the spot where you copied your code from there is this warning:



"WARNING: This extended regular expression feature is considered highly experimental,

and may be changed or deleted without notice."


Apparently your verison of Perl doesn't support this feature.
 
L

Leo 'TheHobbit'

Hi All,

I am new to perl
and am wondering why the following is not running :

$_ = "The brown fox jumps over the lazy dog";
/the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
print "color = $color, animal = $animal\n";

Hi,
this works perfectly here, with perl 5.8.0. Obviously, if you perl
version is older than that it could not work (IIRC code blocks in regex
weren't there even in 5.6.1).
 
T

Tad McClellan

debraj said:
I am new to perl


You should use the docs that _came with_ your version of perl,
else what you see may not work with the version that you
actually have available to you.

/the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;

Sequence (?{...) not recognized at.....

I took it from this link :

http://www.perldoc.com/perl5.8.0/pod/perlre.html
^^^^^
^^^^^

Do you _have_ perl version 5.8.0?

If you use the docs that came with your perl, then you will see
only those features that you can use with your perl.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top