Leser: 24
1 2 3 4 5 6
my @keys = keys (%$hash_ref); foreach my $k (sort {lc $keys[$a] cmp lc $keys[$b]} 0..$#keys) { print "$keys[$k] => "; print (defined $hash_ref -> {$keys[$k]} ? $hash_ref -> {$keys[$k]} : 'NOT DEFINED'); print "\n"; }
1 2 3
if (ref($hash_ref -> {$keys[$k]}) eq 'ARRAY') { my @keys2 = keys (%$keys[$k]); }
my @keys2 = keys %{ $keys[$k] };
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
my @keys = keys (%$hash_ref); foreach my $k (sort {lc $keys[$a] cmp lc $keys[$b]} 0..$#keys) { print "$keys[$k] => "; if (ref($hash_ref -> {$keys[$k]}) eq 'ARRAY') { print "(Untermenge wie folgt:)\n"; my @keys2 = keys %{$hash_ref -> {$keys[$k]}}; foreach my $k2 (sort {lc $keys2[$a] cmp lc $keys2[$b]} 0..$#keys2) { print "\t\t$keys2[$k2] => " . (defined $hash_ref -> {$keys2[$k2]} -> {$keys2[$k2]} ? $hash_ref -> {$keys2[$k2]} -> {$keys2[$k2]} : 'NOT DEFINED') . "\n"; } } else { print (defined $hash_ref -> {$keys[$k]} ? $hash_ref -> {$keys[$k]} : 'NOT DEFINED'); } print "\n"; }
@keys = keys (%$hash_ref)
@keys2 = keys %{$hash_ref -> {$keys[$k]}}
2009-06-03T20:18:52 mikdoeBei dieser Referenz werden ausschließlich Arrays geliefert.
2009-06-03T20:29:13 mikdoeWarum funktioniert dann äquivalent
[...]
nicht für ein "Unterhash"?
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
34
35
36
37
38
39
40
41
42
43
$VAR1 = bless( {
'bank_url' => undef,
'checks' => [
'length',
'bank_code',
'account_number'
],
'account_number' => '12345678',
'branch_code' => undef,
'bank_code' => '12345678',
'bank_code_check' => 'passed',
'alternative_account_number' => undef,
'bic_plausibility_check' => undef,
'IBANformat' => 'DEkk BBBB BBBB CCCC CCCC CC',
'alternative_bank_code' => undef,
'country' => 'DE',
'formatcomment' => 'B = sort code (BLZ), C = account No.',
'branch' => '',
'data_age' => '20090309',
'bank' => 'ING-DiBa',
'bank_address' => undef,
'balance' => '92',
'bic_candidates' => [
bless( {
'city' => 'Frankfurt am Main',
'sampleurl' => undef,
'wwwcount' => '0',
'bic' => 'INGDDEFFXXX'
}, 'BICStruct' ),
bless( {
'city' => undef,
'sampleurl' => 'http://cgi.ebay.de:80/Fruit-of-the-loom-Value-weight-t-Shirt-weiss-XXL-NEU_W0QQitemZ190077916198QQihZ009QQcategoryZ84535QQrdZ1QQcmdZViewItem',
'wwwcount' => '12',
'bic' => 'INGDDEFF'
}, 'BICStruct' )
],
'account_check' => 'passed',
'iban' => 'DE12345',
'length_check' => 'passed',
'account_validation_method' => 'C1',
'account_validation' => "Methode C1, Variante 1, Konto 12345, BLZ 12345, Pr\x{fc}fziffer 9 steht an Position 8, erwartete Pr\x{fc}fziffer: 9. \x{dc}berblick \x{fc}ber die Berechnung: Nimm die Ziffern auf den Positionen 2 bis 7 - hier: 648479 -, multipliziere sie von links nach rechts mit den Gewichten 1,2,1,2,1,2, addiere die Quersummen der Produkte, ziehe 1 davon ab, bilde den Rest der Division durch 11, ziehe das Ergebnis von 10 ab, und das Ergebnis modulo 11 ist die erwartete Pr\x{fc}fziffer.",
'result' => 'passed'
}, 'IBANCalcResStruct' );
my @keys2 = @{$hash_ref -> {$keys[$k]}};
my @keys2 = $hash_ref -> {$keys[$k]};
1
2
3
4
bic_candidates => (Untermenge wie folgt:)
ARRAY(0x20897a4) => NOT DEFINED
checks => (Untermenge wie folgt:)
ARRAY(0x2089390) => NOT DEFINED
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
my @keys = keys (%$hash_ref); foreach my $k (sort {lc $keys[$a] cmp lc $keys[$b]} 0..$#keys) { print "$keys[$k] => "; if (ref($hash_ref -> {$keys[$k]}) eq 'ARRAY') { print "(Untermenge wie folgt:)\n"; # my @keys2 = keys %{$hash_ref -> {$keys[$k]}}; my @keys2 = $hash_ref -> {$keys[$k]}; foreach my $k2 (sort {lc $keys2[$a] cmp lc $keys2[$b]} 0..$#keys2) { print "\t\t$keys2[$k2] => " . (defined $hash_ref -> {$keys2[$k2]} -> {$keys2[$k2]} ? $hash_ref -> {$keys2[$k2]} -> {$keys2[$k2]} : 'NOT DEFINED') . "\n"; } } else { print (defined $hash_ref -> {$keys[$k]} ? $hash_ref -> {$keys[$k]} : 'NOT DEFINED'); } print "\n"; }
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#!/usr/bin/perl -l # vi:ts=4 sw=4 et: use strict; use warnings; my $var = bless( { 'checks' => [ 'length', 'bank_code', 'account_number' ], 'account_number' => '12345678', 'balance' => '92', 'bic_candidates' => [ bless( { 'city' => 'Frankfurt am Main', 'sampleurl' => undef, 'wwwcount' => '0', 'bic' => 'INGDDEFFXXX' }, 'BICStruct' ), bless( { 'city' => undef, 'sampleurl' => 'second', 'wwwcount' => '12', 'bic' => 'INGDDEFF' }, 'BICStruct' ) ], 'account_check' => 'passed', 'iban' => 'DE12345', }, 'IBANCalcResStruct' ); for my $k ( keys %$var ) { if ( $k eq 'checks' ) { # via checks ist ein array erreichbar # alle elemente verarbeiten for my $e ( @{ $var->{$k} } ) { print "$k -> $e"; } # einzelnes element ansprechen print "$k -> ", $var->{$k}->[1]; } elsif ( $k eq 'bic_candidates' ) { # hier ist ein array of hashes erreichbar # jede enthaltene hash-referenz ist ein Objekt des Typs BICStruct for my $e ( @{ $var->{$k} } ) { # $e enthaelt ein Objekt des Typs BICStruct auf Basis eines Hash # dereferenziere wie Hash print $e; } } else { print $k; } } __END__
1 2 3 4 5 6 7 8 9 10 11 12 13 14
my @keys = keys (%$hash_ref); foreach my $k (sort {lc $keys[$a] cmp lc $keys[$b]} 0..$#keys) { print substr($keys[$k] . '.' x 30,0,30) . ' => '; if ($keys[$k] eq 'bic_candidates') { print "(Untermenge wie folgt:)\n"; for my $e ( @{ $hash_ref->{$k} } ) { print "$e\n"; } } else { print (defined $hash_ref -> {$keys[$k]} ? (length $hash_ref -> {$keys[$k]} > 65 ? substr($hash_ref -> {$keys[$k]},0,60) . '...' : $hash_ref -> {$keys[$k]}) : 'NOT DEFINED'); } print "\n"; }
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
account_check................. => passed
account_number................ => 12345678
account_validation............ => Methode C1, Variante 1, Konto 12345678, BLZ 12345678, Pr³f...
account_validation_method..... => C1
alternative_account_number.... => NOT DEFINED
alternative_bank_code......... => NOT DEFINED
balance....................... => 79
bank.......................... => ING-DiBa
bank_address.................. => NOT DEFINED
bank_code..................... => 12345678
bank_code_check............... => passed
bank_url...................... => NOT DEFINED
bic_candidates................ => (Untermenge wie folgt:)
bic_plausibility_check........ => NOT DEFINED
branch........................ =>
branch_code................... => NOT DEFINED
checks........................ => ARRAY(0x2087968)
country....................... => DE
data_age...................... => 20090309
formatcomment................. => B = sort code (BLZ), C = account No.
iban.......................... => DE48500105170648479930
IBANformat.................... => DEkk BBBB BBBB CCCC CCCC CC
length_check.................. => passed
result........................ => passed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
my @keys = keys (%$hash_ref); foreach my $k (sort {lc $keys[$a] cmp lc $keys[$b]} 0..$#keys) { print substr($keys[$k] . '.' x 30,0,30) . ' => '; if ($keys[$k] eq 'bic_candidates') { print "(Untermenge wie folgt:)\n"; for my $e ( @{ $hash_ref->{$k} } ) { print "$e\n"; } } elsif ($keys[$k] eq 'checks') { print "(Untermenge wie folgt:)\n"; for my $e ( @{ $hash_ref->{$k} } ) { print "$k -> $e\n"; } } else { print (defined $hash_ref -> {$keys[$k]} ? (length $hash_ref -> {$keys[$k]} > 65 ? substr($hash_ref -> {$keys[$k]},0,60) . '...' : $hash_ref -> {$keys[$k]}) : 'NOT DEFINED'); } print "\n"; }
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
account_check................. => passed
account_number................ => 648479930
account_validation............ => Methode C1, Variante 1, Konto 0648479930, BLZ 50010517, Pr³f...
account_validation_method..... => C1
alternative_account_number.... => NOT DEFINED
alternative_bank_code......... => NOT DEFINED
balance....................... => 78
bank.......................... => ING-DiBa
bank_address.................. => NOT DEFINED
bank_code..................... => 50010517
bank_code_check............... => passed
bank_url...................... => NOT DEFINED
bic_candidates................ => (Untermenge wie folgt:)
bic_plausibility_check........ => NOT DEFINED
branch........................ =>
branch_code................... => NOT DEFINED
checks........................ => (Untermenge wie folgt:)
country....................... => DE
data_age...................... => 20090309
formatcomment................. => B = sort code (BLZ), C = account No.
iban.......................... => DE48500105170648479930
IBANformat.................... => DEkk BBBB BBBB CCCC CCCC CC
length_check.................. => passed
result........................ => passed
2009-06-03T22:26:37 mikdoeDas ist ein ausdrückliches Testkonto, welches der Dienstanbieter auf seiner Homepage auch verwendet,
QuoteBitte nicht mit so einem Sch... aufhalten.
QuoteEs geht auch nicht um den Inhalt sondern um das Auslesen der Daten!!!
2009-06-03T22:47:52 mikdoeDass Du bei Deinen Recherchen von einem "gültigen" Konto auf ein existierendes geschlossen hast
2009-06-03T22:11:42 pqlaut kontonummern-check ist das konto, was du da gepostet hast, gültig (ob es existiert, ist eine andere frage).
2009-06-03T22:47:52 mikdoeZwischen "nicht echt" und prüfzifferngerecht liegen Welten,
Quotelaß Dir das bitte von einem Bankkaufmann gesagt sein.
QuoteHättest auch einmal mehr fragen können bevor Du einmal "lieber zuviel als zuwenig" anonymisierst.
2009-06-03T22:26:37 mikdoeBitte nicht mit so einem Sch... aufhalten. Es geht auch nicht um den Inhalt sondern um das Auslesen der Daten!!!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# warum nicht direkt den Key nehmen? foreach my $key (sort keys %$hash_ref) { print substr($key . '.' x 30,0,30) . ' => '; if ($key eq 'bic_candidates') { print "(Untermenge wie folgt:)\n"; # du willst doch mit dem Hashkey zugreifen, # nicht mit der Nummer des "Keys"-Array print " $_\n" for( @{ $hash_ref->{$key} } ); } else { print (defined $hash_ref -> {$key} ? (length $hash_ref -> {$key} > 65 ? substr($hash_ref -> {$key},0,60) . '...' : $hash_ref -> {$key}) : 'NOT DEFINED'); } print "\n"; }
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
account_check................. => passed
account_number................ => 648479930
account_validation............ => Methode C1, Variante 1, Konto 0648479930, BLZ 50010517, Pr³f...
account_validation_method..... => C1
alternative_account_number.... => NOT DEFINED
alternative_bank_code......... => NOT DEFINED
balance....................... => 77
bank.......................... => ING-DiBa
bank_address.................. => NOT DEFINED
bank_code..................... => 50010517
bank_code_check............... => passed
bank_url...................... => NOT DEFINED
bic_candidates................ => (Untermenge wie folgt:)
bic_plausibility_check........ => NOT DEFINED
branch........................ =>
branch_code................... => NOT DEFINED
checks........................ => (Untermenge wie folgt:)
country....................... => DE
data_age...................... => 20090309
formatcomment................. => B = sort code (BLZ), C = account No.
iban.......................... => DE48500105170648479930
IBANformat.................... => DEkk BBBB BBBB CCCC CCCC CC
length_check.................. => passed
result........................ => passed
1
2
3
bic_candidates................ => (Untermenge wie folgt:)
BICStruct=HASH(0x2089b7c)
BICStruct=HASH(0x20c8448)
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
foreach my $key (sort keys %$hash_ref) { print substr($key . '.' x 30,0,30) . ' => '; if ($key eq 'bic_candidates') { if(defined($hash_ref->{$key})) { my $typ=ref($hash_ref->{$key}); print "Element hat den typ: $typ\n"; print "(Untermenge wie folgt:)\n"; if($typ eq "ARRAY") { print " $_\n" for( @{ $hash_ref->{$key} } ); } elsif($typ eq "HASH") { print " $_ -> ".$hash_ref->{$key}->{$_}."\n" for(sort keys %{$hash_ref->{$key}}); } else { print Dumper($hash_ref->{$key}); } } else { print "NOT DEFINED"; } } else { print (defined $hash_ref -> {$key} ? (length $hash_ref -> {$key} > 65 ? substr($hash_ref -> {$key},0,60) . '...' : $hash_ref -> {$key}) : 'NOT DEFINED'); } print "\n"; }
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
IBANformat.................... => DEkk BBBB BBBB CCCC CCCC CC
account_check................. => passed
account_number................ => 648479930
account_validation............ => Methode C1, Variante 1, Konto 0648479930, BLZ 50010517, Pr³f...
account_validation_method..... => C1
alternative_account_number.... => NOT DEFINED
alternative_bank_code......... => NOT DEFINED
balance....................... => 75
bank.......................... => ING-DiBa
bank_address.................. => NOT DEFINED
bank_code..................... => 50010517
bank_code_check............... => passed
bank_url...................... => NOT DEFINED
bic_candidates................ => Element hat den typ: ARRAY
(Untermenge wie folgt:)
BICStruct=HASH(0x208cb54)
BICStruct=HASH(0x20c8e8c)
bic_plausibility_check........ => NOT DEFINED
branch........................ =>
branch_code................... => NOT DEFINED
checks........................ => ARRAY(0x208a420)
country....................... => DE
data_age...................... => 20090309
formatcomment................. => B = sort code (BLZ), C = account No.
iban.......................... => DE48500105170648479930
length_check.................. => passed
result........................ => passed
1 2 3 4 5
#!/usr/bin/perl -w use strict; use diagnostics; use warnings; use Data::Dumper;
2009-06-03T22:56:03 mikdoeLeider noch immer nicht, schau:
Code: (dl )1
2
3
4
5
6bic_candidates................ => Element hat den typ: ARRAY
(Untermenge wie folgt:)
BICStruct=HASH(0x208cb54)
BICStruct=HASH(0x20c8e8c)
bic_plausibility_check........ => NOT DEFINED
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 34 35 36
foreach my $key (sort keys %$hash_ref) { print substr($key . '.' x 30,0,30) . ' => '; if ($key eq 'bic_candidates') { if(defined($hash_ref->{$key})) { my $typ=ref($hash_ref->{$key}); print "Element hat den typ: $typ\n"; print "(Untermenge wie folgt:)\n"; if($typ eq "ARRAY") { # Die im Array enthaltenen Hashes auslesen. for my $i (0..$#{$hash_ref->{$key}}) { print " Element $i:\n"; for my $inkey (sort keys %{$hash_ref->{$key}->[$i]}) { my $val = $hash_ref->{$key}->[$i]->{$inkey}; print " $inkey -> $val\n"; } } # was kommt nun raus? } else { print Dumper($hash_ref->{$key}); } } else { print "NOT DEFINED"; } } else { print (defined $hash_ref -> {$key} ? (length $hash_ref -> {$key} > 65 ? substr($hash_ref -> {$key},0,60) . '...' : $hash_ref -> {$key}) : 'NOT DEFINED'); } print "\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
sub make_hash { my $hash_ref = shift; my %return_hash; foreach my $key (keys %$hash_ref) { if ($key eq 'bic_candidates') { for my $i (0..$#{$hash_ref->{$key}}) { for my $inkey (sort keys %{$hash_ref->{$key}->[$i]}) { $return_hash{$key}{$i}{$inkey} = (defined $hash_ref->{$key}->[$i]->{$inkey} ? $hash_ref->{$key}->[$i]->{$inkey} : undef); } } } elsif ($key eq 'checks') { for my $i (@{$hash_ref->{$key}}) { $return_hash{$key}{$i} = defined; } } else { $return_hash{$key} = (defined $hash_ref -> {$key} ? $hash_ref -> {$key} : undef); } } return %return_hash; }