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



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";'
.



Relevant Pages

  • Intaglio Fine Art Prints
    ... etchings and engravings prints (animals, birds, dogs, cats, horses, ... hunting, flowers, military). ... Prev by Date: ...
    (sci.med.dentistry)
  • Re: 2nd and 4th Wednesdays formula?
    ... > would like to be able to print a list instead of hunting down a ... > calendar and counting. ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: 2nd and 4th Wednesdays formula?
    ... > would like to be able to print a list instead of hunting down a ... > calendar and counting. ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: 2nd and 4th Wednesdays formula?
    ... >would like to be able to print a list instead of hunting down a ... >calendar and counting. ... Prev by Date: ...
    (microsoft.public.excel.worksheet.functions)
  • Re: IDEs Classic vs. New?
    ... You really prefer all that scrolling and hunting for components? ... Nick Hodges -- TeamB ... Prev by Date: ...
    (borland.public.delphi.non-technical)