You can chain these suckers... so to ensure you do nothing if $x doesn't appear in %my_hash:
noting that if $x does not exist, what you want is an empty list.foreach $key ( ($x eq 'key_1') ? keys %my_hash : exists $my_hash($x) +? $x : () ) { do a bunch of stuff }
In reply to Re^5: Loop once on condition 1, many times on cond. 2?
by gone2015
in thread Loop once on condition 1, many times on cond. 2?
by punch_card_don
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |