princepawn has asked for the wisdom of the Perl Monks concerning the following question:
then sometimes $H{y} might equal 'z' because the elements in the list simply shift up. 2: I tried to use a ternary operator to insure that each value of a hash had some value to avoid the above as follows:%H = ( 'x' => 'y', 'y' => $undef_var, 'z' = 'a' );
But I am told that something is wrong with my warn line...#!/usr/bin/perl %p = ( 'a' => 'B', 'z' => defined($x) ? $x : '', 'c' => 'D'); use Data::Dumper; #warn Data::Dumper->Dump([\%p],['p']); warn $p{z};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undefined Hash Values and Ternary Operators
by KM (Priest) on May 25, 2000 at 21:12 UTC | |
|
RE: Undefined Hash Values and Ternary Operators
by mdillon (Priest) on May 25, 2000 at 21:19 UTC | |
|
Re: Undefined Hash Values and Ternary Operators
by Adam (Vicar) on May 25, 2000 at 21:07 UTC | |
by merlyn (Sage) on May 25, 2000 at 21:13 UTC |