in reply to cleaning up spaces on either side of an extracted string
to this:$index =~ m"(.*?): (.*)"; my $key = $1; my $val = $2;
my $key=''; my $value=''; if ($index =~ m"(.*?): (.*)") { $key = $1; $val = $2; }
Never assume a match will exist. Consider this piece of careless code : )
'boo!' =~ /(.*)/; $test_string = "this is a test sentence."; $test_string =~ /(\w+)$/; my $last_word=$1; print "$last_word\n";
If you assume a match will take place, you'd get extremely confused :)
cLive ;-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: cleaning up spaces on either side of an extracted string
by pacman (Initiate) on Mar 19, 2004 at 09:12 UTC |