Hi there!
This may or may not be a beginners question. If not, please let me know
where I ought to post. :-)
I have a data structure, a simple array. It is made up of sections of
files I have slurped;
sub _build_packages {
use Perl6::Slurp;
my @pkgs;
# iterate over the packages slurping them into one
map { push @pkgs, (slurp $_, {irs => qr/\n\n/xms}) } @packages;
return \...@pkgs;
}
(The above code is in the class declaration)
Now in my program which subclasses that array ref, after de-referencing
I have this idiom;
my %versions;
map {
my $package = $_;
# autovivfy a hash with versions of packages
$versions{$package} = [ ] unless exists $versions{$package};
} @packages
So my questions are:
Is this an efficient way to do this? Am I using the idiom correctly?
Could I make it more readable? Is my predilection for map over foreach making
this less readable? Or is that only a question of style?
Thanks for any feedback.
Regards,
Jeremiah
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/