G
guthrie
sorry for the beginner question, but...
With this code
my $img = "0-12345-abc";
print " Match.1 ", (defined $img);
print " Match.2 ", ($img =~ /\S/);
print " Matched::", $1;
print " Match.3 ", ($img =~ /^(\d)-(\d+)-(\w)$/);
print " Matched::", $1, ", ", $2, ", ", $3;
I expected:
true, true, "012345-abc", true,
and then: 0, 12345, abc
Instead I get:
true true "" false
"" "" ""
Actually: img= (0-52557-wind)
Match.1 1 Match.2 1 Matched::
Match.3 Matched::, ,
Seems simple enough, what am I missing!
- why doesn't the full string first match against /\S/ return the
string
- why doesn't the second (extracting) match work.
The actual code I'm trying for is:
if(defined $img and $img =~ /\S/) {
if ($img =~ /^(\d)-(\d+)-(\w)$/)
{ my ($t, $zip, $type) = ($1, $2, $3); }
else { die "ERROR: invalid URL arguments :: ${img}\n";}
print "Debug: (", $t, ", ", $zip, ", ", $type, ")\n"; ##
Debug...
Thanks for any hints. Sorry for the confusion!
Greg
With this code
my $img = "0-12345-abc";
print " Match.1 ", (defined $img);
print " Match.2 ", ($img =~ /\S/);
print " Matched::", $1;
print " Match.3 ", ($img =~ /^(\d)-(\d+)-(\w)$/);
print " Matched::", $1, ", ", $2, ", ", $3;
I expected:
true, true, "012345-abc", true,
and then: 0, 12345, abc
Instead I get:
true true "" false
"" "" ""
Actually: img= (0-52557-wind)
Match.1 1 Match.2 1 Matched::
Match.3 Matched::, ,
Seems simple enough, what am I missing!
- why doesn't the full string first match against /\S/ return the
string
- why doesn't the second (extracting) match work.
The actual code I'm trying for is:
if(defined $img and $img =~ /\S/) {
if ($img =~ /^(\d)-(\d+)-(\w)$/)
{ my ($t, $zip, $type) = ($1, $2, $3); }
else { die "ERROR: invalid URL arguments :: ${img}\n";}
print "Debug: (", $t, ", ", $zip, ", ", $type, ")\n"; ##
Debug...
Thanks for any hints. Sorry for the confusion!
Greg