<snip>
> #!/usr/bin/perl
>
> use strict;
>
> my %hash = (
> key1 => 'value 1',
> key2 => 'value 2',
> key3 => 'value 3',
> );
>
> print_hash(\%hash, '=>');
>
> sub print_hash {
> my ($hash, $connector) = @_;
>
> foreach my $key (sort keys %$hash) {
> print "$key $connector $$hash{$key}\n";
> }
> }
I'm new to perl, but isn't this easier to understand:
#!/usr/bin/perl
use strict;
my %hash = (
key1 => 'value 1',
key2 => 'value 2',
key3 => 'value 3',
);
print_hash(\%hash);
sub print_hash {
my ($hash) = @_;
foreach my $key (sort keys %$hash) {
print "$key => $hash->{$key}\n";
}
}
I took out the $connector and dereferenced with ->.
I am pretty new to Perl, and it took me awhile to understand why you passed
=> to the sub, and what $connector was..
I'm just sayin :)
--
T.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]