thanks ikegami. i don't get the " won't compile comments"..
>type 754047.pl $value =~ s/\D//g; $value =~ $1 if( $value =~ /(\d+)/ ){ $value =~ $1 } else { undef $value; } >perl -c 754047.pl syntax error at 754047.pl line 3, near "){" 754047.pl had compilation errors.
the two lines fix a bug in the script which "seems" to be working ok on my host now..??
Seems is the operative word
my $value = "abc456def"; $_ = $value; $value = m/(\d+)/; print "$value\n"; # Prints 1, not 456
Fix:
my $value = "abc456def"; $_ = $value; ($value) = m/(\d+)/; print "$value\n"; # Prints 456
A more elegant version that doesn't clobber a global:
my $value = "abc456def"; ($value) = $value =~ m/(\d+)/; print "$value\n"; # Prints 456
In reply to Re^2: it seems i don't understand =~
by ikegami
in thread it seems i don't understand =~
by partymeeple
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |