Paul Kraus wrote:
Why does this work....
my $date = 'one   |  two   |three      |';
my @record = map ( whitespace($_), (split /\|/,$_) );
sub whitespace {
  my $string = shift;
  $string =~ s/^\s+|\s+$//g;
  return $string;
}

but this does not ....
my @record = map ( $_=~ s/^\s+|\s+$//g,(split /\|/,$_) );

map() returns the result of the expression "$_=~ s/^\s+|\s+$//g" NOT the value of $_. If you want it to return the value of $_:


my @record = map { s/^\s+//; s/\s+$//; $_ } split /\|/;



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to