in reply to map a list
use strict; use warnings; my $str = q{a,b=c,e=#f,ghi}; my @result = map { my $res; m {(?x) ^ (?(?=([a-z])$) (?{(sub {($res) = @_})->(qq{$1=>fn($1)})}) | (?(?=([a-z])=([a-z])$) (?{(sub {($res) = @_})->(qq{$2=>$3})}) | (?(?=([a-z])=\#([a-z])$) (?{(sub {($res) = @_})->(qq{$4=>fn($5)})}) | (?{(sub {($res) = @_})->(q{???})}) ) ) ) }; $res } split m{,}, $str; print qq{@result\n};
It prints
a=>fn(a) b=>c e=>fn(f) ???
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map a list
by ikegami (Patriarch) on Mar 12, 2007 at 23:30 UTC |