Second question ---
Code:
%hash = (1=>2
2 =>3
3 =>4);
$hash{2} = 5;
$hash = 6;
%hash = reverse(%hash);
for ($i = 1; $i < 5; $i++)
{
delete($hash{$1});
}
print(%hash)
one gets some pretty nasty remarks from perl since there are missing ,'s. It should read something like
%hash=(1=>2,2=>3,...);
moreover that "delete($hash{$1})" probably should be "delete($hash{$i})". Maybe that what's wrong?
Learn to be lazy --- Use "use strict;" "use warnings;" as in
Code:
#!/usr/bin/perl
use strict;
use warnings;
my %hash = (1=>2
,2 =>3
,3 =>4);
$hash{2} = 5;
my($hash) = 6;
%hash = reverse(%hash);
for (my($i) = 1; $i < 5; $i++)
{
delete($hash{$1});
};
print(%hash)