Steve Grazzini wrote:
> On Sun, Jul 06, 2003 at 11:20:03AM -0000, mark  sony wrote:
> > $_ = "The brown fox jumps over the lazy dog";
> >   /the (\S+)(?{ $color = $^N }) (\S+)(?{ $animal = $^N })/i;
> >   print "color = $color, animal = $animal\n";
> >
> > When I run the program it gives :color = , animal =
> >
> > I took it from this link :
> > http://www.perldoc.com/perl5.8.0/pod/perlre.html
>                              ^^^^^
> $^N is new in 5.8.0.
>
> In general, it's less frustrating to read the documentation
> that comes with *your* version of Perl.
>
>     % perl -v
>     % perldoc perlre
>     % perldoc perlvar
>
> In this case you can probably use $+ instead.

$+ will return only the last captured string so you would need to
process your text in two passes to get this result. For versions < 5.8
this will do what you want:

my ($color, $animal) = /the (\w+) (\w+)/i;


which, to my mind, is a lot neater anyway.

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to