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{$package} = $version
>>       } @packages
> 
> You don't need to store an anonymous array before a push

Ah okay.

> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> 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;

I learned a bit about data dumper here, thanks!

> 
> my %hash = ();
> for my $key ( 'a' .. 'z' ){
>  for my $value ( 'a' .. $key ){
>    push @{ $hash{$key} }, $value;
>  }
> }
> print 'hash = ', Dumper \%hash;

Thanks Shawn.

Jeremiah


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to