Thread An key bei values Schleife
(34 answers)
Opened by bianca at 2010-04-14 12:07
Überschlagt Euch doch nicht gleich.
Ich möchte im grep{} ein split machen und das split-Ergebnis wiederum ist key in einem anderen Hash. Um nicht schon "Use of uninitialized value" bei Verwendung des Split-Ergebnisses zu bekommen will ich das vorher abfragen. Hier der Code: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/usr/bin/perl -w use strict; use warnings; my %user = ( 1 => 'hallo|hallo|hallo|hallo|hallo', 2 => 'hallo|hallo|hallo', ); my %foo = ( 1 => 'hallo', ); foreach my $user ( grep { (split /\|/,$user{$_})[4] # das matcht auf garnichts #defined (split /\|/,$user{$_})[4] schmeisst Syntax und Implicit-Error && defined $foo{(split /\|/,$user{$_})[4]} } keys %user ) { print "Treffer: $user\n"; } Edit: Daher hatte ich mit values versucht aber das ist bestimmt Bullshit. Last edited: 2010-04-14 12:26:23 +0200 (CEST) 10 print "Hallo"
20 goto 10 |