B
Brian Wakem
This is driving me mad. I've been chasing a bug in a program for 3hrs, I
have narrowed it down to this complete and working code.
This is the *exact code* I am running, followed by the actual output.
I've tried it on two machines, which run different versions of perl and I
get the same result.
Please, someone tell me what the hell is going on here, why doesn't the
regex in sub1 match the 3rd and 4th time through?
#!/usr/bin/perl
use strict;
use warnings;
sub1();
sub1();
if ('a' =~ m/a/) {
sub1();
}
sub1();
sub sub1 {
print "This is sub1\n";
if ('someword' =~ m//) {
print "Regex matches\n";
}
else {
print "Regex does not match, what on Earth is going on here?\n";
}
}
$ perl -v
This is perl, v5.8.6 built for i386-linux
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
$ perl tmp37.pl
This is sub1
Regex matches
This is sub1
Regex matches
This is sub1
Regex does not match, what on Earth is going on here?
This is sub1
Regex does not match, what on Earth is going on here?
$
have narrowed it down to this complete and working code.
This is the *exact code* I am running, followed by the actual output.
I've tried it on two machines, which run different versions of perl and I
get the same result.
Please, someone tell me what the hell is going on here, why doesn't the
regex in sub1 match the 3rd and 4th time through?
#!/usr/bin/perl
use strict;
use warnings;
sub1();
sub1();
if ('a' =~ m/a/) {
sub1();
}
sub1();
sub sub1 {
print "This is sub1\n";
if ('someword' =~ m//) {
print "Regex matches\n";
}
else {
print "Regex does not match, what on Earth is going on here?\n";
}
}
$ perl -v
This is perl, v5.8.6 built for i386-linux
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
$ perl tmp37.pl
This is sub1
Regex matches
This is sub1
Regex matches
This is sub1
Regex does not match, what on Earth is going on here?
This is sub1
Regex does not match, what on Earth is going on here?
$