in reply to map a list
use strict; use warnings; my $str = "a,b=c,e=#f"; my @result = map { /(\w+)(=(#?)(\w+))?/; defined $3 && $3 eq '#' ? "$1=>fn($4)" : defined $2 ? "$1=>$4" : "$1=>fn($1)" } split ',', $str; print "@result";
Prints:
a=>fn(a) b=>c e=>fn(f)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map a list
by merlyn (Sage) on Mar 12, 2007 at 20:38 UTC | |
by GrandFather (Saint) on Mar 12, 2007 at 21:00 UTC | |
|
Re^2: map a list
by evil_otto (Novice) on Mar 12, 2007 at 19:31 UTC | |
by GrandFather (Saint) on Mar 12, 2007 at 19:38 UTC |