On Sunday, Jul 6, 2003, at 04:20 US/Pacific, mark sony wrote:


Hi All,

Can anyone plz explain to me why this one is not working :

$_ = "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

first off you are running it in perl 5.8, and not a previous version? if so, it should work. I of course ran the code:

    #!/usr/bin/perl -w
    use strict;

my ($color, $animal)=('','');

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

when I ran that code under 5.6.1 I got

vladimir: 105:] perl !$
perl junk.plx
Use of uninitialized value in concatenation (.) or string at junk.plx line 8.
Use of uninitialized value in concatenation (.) or string at junk.plx line 8.
color = , animal =
vladimir: 106:]


ciao
drieux

---


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



Reply via email to