Thread Leere Daten in Array ersetzen
(23 answers)
Opened by Kean at 2011-09-16 13:25 2013-08-22T12:11:54 Kean klar ;) Kopier einfach mal den Code und führe aus. Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 #!/usr/bin/perl package ValideHashValue; use Tie::Hash; use base 'Tie::StdHash'; use strict; use warnings; sub TIEHASH{ my $class = shift; my $href = shift; return bless $href, $class; } sub FETCH{ my $self = shift; my $key = shift; return defined $self->{$key} ? $self->{$key} : 'das war mal undef'; } package main; use strict; use warnings; my %hash = (); print $hash{foo}; # Use of uninitialized value in print ... # now, using tie: tie my %h, 'ValideHashValue', \%hash; print $h{foo}; # das war mal undef PS/Edit: Guck dir mal die Slice-Option für an (Perl DBI). Das ist oft nützlich. Last edited: 2013-08-22 15:42:53 +0200 (CEST) |