in reply to Re: map and each?
in thread map and each?
then you would call it by genHash(\%somehash)sub genHash { my $hashn = shift; return "\%$hashn = (\n" . join(",\n", map { $key = $_; "'$key' => " . (ref $$hashn{$_} ? '{' . join(",\n", map { "'$_' => qq~" . safeTilde($$hashn{$key}->{$_}) . '~' } keys %{$$hashn{$key}}) . '}' : 'qq~' . safeTilde($$hashn{$key}) . '~' ) } keys %$hashn) . ");\n"; } sub safeTilde { my $code = shift; $code =~ s/\~/\\~/g; return $code; }
Edit kudra, 2002-05-27 s/pre/code
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: map and each?
by Kanji (Parson) on May 27, 2002 at 02:39 UTC | |
|
•Re: Re: Re: map and each?
by merlyn (Sage) on May 27, 2002 at 13:49 UTC |