in reply to map not returning

Without much modification of your code:
my $params = q('196','berg',NULL,NULL); my @list_of_params = map { s/^\'(.*?)\'$/$1/m; $_} map { $_ eq 'NULL' ? 'undef' : $_ } split(/\s*\,\s*/,$params);

artist
========

Replies are listed 'Best First'.
Re: Re: map not returning
by davido (Cardinal) on Sep 11, 2003 at 00:42 UTC
    While that's a great use of map if you're trying to win an obfu contest, that method is too aggressive at removing single quotes. He specified that he wanted to remove single quotes from the number, not from the word 'berg'.

    It would work better like this:

    my @list_of_params = map { s/^'(\d+?)'$/$1/ } map { $_ eq 'NULL' ? 'undef' : $_ } split (/\s*,\s*/,$params);

    Dave

    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein

      Thanks I got it fixed.