Re: Autovivification of hash from an array

2009-11-30 Thread Shawn H Corey
Dr.Ruud wrote: > Shawn H Corey wrote: > >> use Data::Dumper; >> >> # Make Data::Dumper pretty >> $Data::Dumper::Sortkeys = 1; >> $Data::Dumper::Indent = 1; >> >> # Set maximum depth for Data::Dumper, zero means unlimited >> $Data::Dumper::Maxdepth = 0; > > Variant: > > use Data::Dumper; > {pac

Re: Autovivification of hash from an array

2009-11-30 Thread Dr.Ruud
Shawn H Corey wrote: use Data::Dumper; # Make Data::Dumper pretty $Data::Dumper::Sortkeys = 1; $Data::Dumper::Indent = 1; # Set maximum depth for Data::Dumper, zero means unlimited $Data::Dumper::Maxdepth = 0; Variant: use Data::Dumper; {package Data::Dumper;our($Indent,$Sortkeys,$Terse,$

Re: Autovivification of hash from an array

2009-11-28 Thread Uri Guttman
> "JF" == Jeremiah Foster writes: JF> # autovivfy a hash with versions of packages JF> $versions{$package} = [ ] unless exists $versions{$package}; that is MANUALLY vivifying an array. if you just pushed to the slot with a dereference, that would be autovivifying. only p

Re: Autovivification of hash from an array

2009-11-28 Thread John W. Krahn
Jeremiah Foster wrote: Hi there! Hello, 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; Do you reall

Re: Autovivification of hash from an array

2009-11-28 Thread Jeremiah Foster
On Nov 28, 2009, at 15:25, Shawn H Corey wrote: > Jeremiah Foster wrote: >>> my %versions; >>> map { >>> my $package = $_; >>> # autovivfy a hash with versions of packages >>> $versions{$package} = [ ] unless exists $versions{$package}; >> push @{ $versions{$

Re: Autovivification of hash from an array

2009-11-28 Thread Shawn H Corey
Jeremiah Foster wrote: >> my %versions; >>map { >> my $package = $_; >> # autovivfy a hash with versions of packages >> $versions{$package} = [ ] unless exists $versions{$package}; > push @{ $versions{$package} = $version >} @packages You don't

Re: Autovivification of hash from an array

2009-11-28 Thread Jeremiah Foster
Edit: Added missing 'push' to code example. On Nov 28, 2009, at 14:13, Jeremiah Foster wrote: > 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