in reply to map not returning
You have several problems.
If you had warnings enabled you would see that this causes two "Use of uninitialized value in substitution (s///) at ..." messages. One for each of the undefs.
A simple solution to this is to reverse the order of your maps.
The simple answer here is to make sure that the result of the map (the last value in the code block) is $_.
This may just be words, but if you really only want to strip them from the number(s) then you should change thematch in the substitution to s/^\'(\d+?)\'$/....
Your also backwacking more than is necessary. Putting that all together we get
my $params = "'196', 'berg',NULL,NULL"; my @list_of_params = map { $_ eq 'NULL' ? undef : $_ } map { s/^'(\d+?)'$/$1/m; $_ } split /\s*,\s*/, $params ;
It's probably not the way I would have done it, but it does correct some errors and produce the output you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: map not returning
by ctilmes (Vicar) on Sep 11, 2003 at 11:18 UTC |