Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > lookaround

Reply
Thread Tools

lookaround

 
 
debraj
Guest
Posts: n/a
 
      07-06-2003
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
 
Reply With Quote
 
 
 
 
Andras Malatinszky
Guest
Posts: n/a
 
      07-06-2003


debraj wrote:

> 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.



 
Reply With Quote
 
 
 
 
Leo 'TheHobbit'
Guest
Posts: n/a
 
      07-06-2003
On Sun, 06 Jul 2003 04:45:04 +0000, debraj wrote:

> 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).

--
Leo "TheHobbit"
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darknes bind them
In the land of Mordor where the Shadow lie.

 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      07-06-2003
debraj <(E-Mail Removed)> wrote:

> 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.


--
Tad McClellan SGML consulting
http://www.velocityreviews.com/forums/(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
doubt with positive lookaround hemant Ruby 4 12-06-2006 06:07 AM



Advertisments