Jim wrote:
> 
> I've never encountered this before but I have to be doing something wrong.

Yes, you are.  This is the documented behaviour of the numeric variables
and is why we always tell beginners to use them only if the regular
expression matched.


> snippet of code:
> 
> ]$ perl -e '
> > $var = "Company Online (Company Systems) NETBLK-COM-5BLK
> (NET-24-256-0-0-1)";
> > $var =~ /.*? \(.*\) (.*?) \(.*?\)/;
> > print $1,"\n";

print "$1\n" if $var =~ /.*? \(.*\) (.*?) \(.*?\)/;


> > $var = "NetBlock: NETBLK-10H-6BLK";
> > $var =~ /sdddd\(.*?\) (.*?) \(.*?\)/;
> > print $1,"\n";

print "$1\n" if $var =~ /sdddd\(.*?\) (.*?) \(.*?\)/;


> > '
> NETBLK-COM-5BLK
> NETBLK-COM-5BLK
> 
> Why isn't $1 getting updated with the next implicit match?  It should fail
> but its returning the first $1 match.  I can't unset $1 because it is a
> read-only variable.  This doesn't even work if I change the second $var to
> $var2 because of course $1 is the same the way through.

$1, $2, $3, etc. are only set on a successful match otherwise they
retain the value from the previous successful match.


John
-- 
use Perl;
program
fulfillment

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

Reply via email to