Re: print statement creates key in hash with reference to empty array??



A. Sinan Unur schreef:

> if( exists $hash{$key} ) {
> print "$hash{$key}\n";
> }


Hunting for alternatives:

$ echo 'if( exists $hash{$key} ) { print "$hash($key)\n"; }' \
| perl -MO=Deparse,-x7

exists $hash{$key} and do {
print "$hash($key)\n"
};

I don't know why the do-block is needed.


$ echo 'print "$hash{$key}\n" if exists $hash{$key};' \
| perl -MO=Deparse,-x7

exists $hash{$key} and print "$hash{$key}\n";

--
Affijn, Ruud

"Gewoon is een tijger."
.



Relevant Pages