On 12-02-13 11:41 AM, lina wrote:
sub display_hash
{
my (%hash) = @_;
foreach (%hash)
{
print "$_ => $hash{$_}\n";
}
}
display_hash('name' => 'Mar', 'distance' => 'forget');
distance => forget
Use of uninitialized value in concatenation (.) or string at
./subroutines_examples.pl line 38.
forget =>
name => Mar
Use of uninitialized value in concatenation (.) or string at
./subroutines_examples.pl line 38.
Mar =>
Thanks ahead for any suggestion,
foreach my $key ( keys %hash ){
print "$key => $hash{$key}\n";
}
See `perldoc -f keys`
Also, you should always use a my variable for the foreach variable.
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/