Re: print statement creates key in hash with reference to empty array??
- From: Abigail <abigail@xxxxxxxxxx>
- Date: 31 Jan 2006 21:46:09 GMT
Dr.Ruud (rvtol+news@xxxxxxxxxxxx) wrote on MMMMDXXXVI September MCMXCIII
in <URL:news:dro98o.vk.1@xxxxxxxxxxxxxxxxx>:
== 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.
Because the then part of an if statement is a block. 'do {}' turns a block
into an expression.
== $ echo 'print "$hash{$key}\n" if exists $hash{$key};' \
== | perl -MO=Deparse,-x7
==
== exists $hash{$key} and print "$hash{$key}\n";
Here, the if is a "statement" modifier, which is badly named, as it may
only follow an expression.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
.
- References:
- print statement creates key in hash with reference to empty array??
- From: rhorizon74
- Re: print statement creates key in hash with reference to empty array??
- From: A. Sinan Unur
- Re: print statement creates key in hash with reference to empty array??
- From: Dr.Ruud
- print statement creates key in hash with reference to empty array??
- Prev by Date: Re: print statement creates key in hash with reference to empty array??
- Next by Date: Modules using each other
- Previous by thread: Re: print statement creates key in hash with reference to empty array??
- Next by thread: Re: print statement creates key in hash with reference to empty array??
- Index(es):
Relevant Pages
|