Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, is there a way to print only few elements from a hash. Thanks
  • Comment on is there a way to print only few key values from a hash

Replies are listed 'Best First'.
Re: is there a way to print only few key values from a hash
by DStaal (Chaplain) on May 29, 2009 at 21:08 UTC

    Sure! There are lots of ways. Loops, slices, specifying in code...

    What do you want to do, and what have you tried.

Re: is there a way to print only few key values from a hash
by jethro (Monsignor) on May 29, 2009 at 21:28 UTC

    What do you mean? A few random values? Your question is very unspecific

    You can print selected values with

    foreach my $key (keys %hash) { print $hash{$key} if (somecondition); }
Re: is there a way to print only few key values from a hash
by akho (Hermit) on May 29, 2009 at 21:09 UTC
    Yes.

    Could you elaborate? What exactly do you want?