in reply to Hashing uninitialized values when no value returned from DBI sql select
In Perl 5.10, you can say,
$myhash{$val_1} = $val_2 // '';
Otherwise, I might say,
$myhash{$val_1} = defined $val_2 ? $val_2 : '';
Update: And you can always turn off warnings.
foreach $val_1 (keys %myhash) { no warnings 'uninitialized'; print "myhash{$val_1} = $myhash{$val_1}\n"; }
You can selectively and lexically turn off/on warnings as you like. Generally it's a good idea to limit the lack of warnings to the smallest scope possible. See perllexwarn for a list of the warnings categories you can toggle.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hashing uninitialized values when no value returned from DBI sql select
by punch_card_don (Curate) on Feb 27, 2008 at 20:51 UTC | |
by FunkyMonk (Bishop) on Feb 27, 2008 at 23:48 UTC | |
by punch_card_don (Curate) on Feb 28, 2008 at 03:49 UTC | |
by kyle (Abbot) on Feb 27, 2008 at 21:01 UTC |