in reply to map not returning

If I understand your question.....

$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

    Your replacing the word NULL with the word "undef" rather than the value undef which the OP was doing.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.