A
alidixon
I've been having some trouble with regex's.
In the following example, the first call to extract() prints the value
I expect - 'string'.
However, the second call fails to find a match in the regex, and
displays the error:
Use of uninitialized value in concatenation (.) or string at test.pl
line 22.
''
I'm using windows XP, and tested this on perl v5.8.7 and v5.8.8.
Kind Regards
Ali
#!/usr/bin/perl
use warnings;
use strict;
my @names;
my $temp = "/testbench/string";
extract($temp);
my $temp1 = "/testbench/string1/string2/string3";
extract($temp1);
sub extract {
my $string = shift;
print ("extract::string: $string.\n ");
my $name;
($name) = ($string =~ ?^.*/(\w+)$?);
print ("'$name'\n");
}
In the following example, the first call to extract() prints the value
I expect - 'string'.
However, the second call fails to find a match in the regex, and
displays the error:
Use of uninitialized value in concatenation (.) or string at test.pl
line 22.
''
I'm using windows XP, and tested this on perl v5.8.7 and v5.8.8.
Kind Regards
Ali
#!/usr/bin/perl
use warnings;
use strict;
my @names;
my $temp = "/testbench/string";
extract($temp);
my $temp1 = "/testbench/string1/string2/string3";
extract($temp1);
sub extract {
my $string = shift;
print ("extract::string: $string.\n ");
my $name;
($name) = ($string =~ ?^.*/(\w+)$?);
print ("'$name'\n");
}