On Mon, 2008-12-22 at 03:49 -0800, RP wrote:
> Question: I am not able to understand the statement -"@fake_array
> { sort {$a <=> $b} keys %fake_array }".
> I understood that we are sorting the keys of a hash %fake_array. But
> what is the meaning of @fake_array here???
> 
> Appreciate your help to explain me this.
> 

This notation: @hash{ }
is a hash slice. See `perldoc perldata` and search for "Slices".

it will return the values of a hash that correspond to the keys inside
the curly brackets.

Example:
#!/usr/bin/perl

use strict;
use warnings;

my %hash = (
  a => 1,
  b => 2,
  c => 3,
);

my @values = @hash{ 'a', 'c' };
print "values for 'a' and 'c': @values\n";

@values = @hash{ 'a' .. 'c' };
print "values for 'a' to 'c': @values\n";

__END__


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Believe in the Gods but row away from the rocks.
  -- ancient Hindu proverb


-- 
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