Thread Frage zu Hash (15 answers)
Opened by jason-duff at 2006-01-16 12:13

bloonix
 2006-01-16 13:58
#61931 #61931
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
[quote=jason-duff,16.01.2006, 11:13]%dirs = {
'./space/dir/dirname1' => Wert1
'./space/dir/dirname2' => Wert2
'./space/dir/dirname3' => Wert3
'./space/dir/dirname4' => Wert4
};
[/quote]

da sind einige Fehler drin! Komma fehlt, Quoting auf der
rechten Seite und die Zuweisung ist auch nicht korrekt.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl -w
use strict;

my %dirs = (
  './space/dir/dirname1' => 'Wert1',
  './space/dir/dirname2' => 'Wert2',
  './space/dir/dirname3' => 'Wert3',
  './space/dir/dirname4' => 'Wert4',
);

my %other_dirs = (
  dirname1 => 'dirname4',
  dirname2 => 'dirname5',
  dirname3 => 'dirname99',
  dirname4 => 'dirname100'
);

foreach (keys %dirs) {
  # matched bis zum letzten Slash, ein Slash muss enthalten sein
  next unless /^(.+)\/(.+)$/ && exists $other_dirs{$2};
  function1($_,$dirs{$_},"$1/$other_dirs{$2}",$other_dirs{$2});
}
\n\n

<!--EDIT|opi|1137412823-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Frage zu Hash