lookaround

Discussion in 'Perl Misc' started by debraj, Jul 6, 2003.

  1. debraj

    debraj Guest

    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
     
    debraj, Jul 6, 2003
    #1
    1. Advertising

  2. 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.
     
    Andras Malatinszky, Jul 6, 2003
    #2
    1. Advertising

  3. 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.
     
    Leo 'TheHobbit', Jul 6, 2003
    #3
  4. debraj <> 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
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jul 6, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hemant
    Replies:
    4
    Views:
    105
    hemant
    Dec 6, 2006
Loading...

Share This Page