in reply to map not returning
$param =~ s/'(\d+)'/$1/g; $param =~ s/NULL/undef/g; @list_of_params = split /\s*,\s*/, $param;
Map would be useful if you were already dealing with a list. No point splitting things into a list before you've taken advantage regular expressions to substitute where necessary.
UPDATE: Thanks BrowserUK for the little tip. So as to actually substitute NULL with the undef value (rather than the 'undef' string), I propose this:
$param =~ s/'(\d+)'/$1/g; @list_of_params = map { ($_ eq 'NULL') ? undef : $_ } split( /\s*,\s*/, $param );
Yes, it can be done in a one-liner using two map calls, but I still think that's making it a little too complex (and difficult to maintain in the future).
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: map not returning
by BrowserUk (Patriarch) on Sep 11, 2003 at 02:03 UTC |