Leser: 1
|< 1 2 >| | 13 Einträge, 2 Seiten |
1
2
print&f(($_=(3x3)."3+33")=~s=3(?![^3]|$)=&f=eg);
sub f{eval(@_?$_:"'$&+'x3");}
$main->Label(-text=>'test')->pack
$main->Label(-text=>'zum Beenden anklicken')->pack->bind('<1>'=>\&exit)
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
use Tk;
use Data::Dumper;
$hash{'KEY'}="VALUE";
$hash{'SUBKEY1'}{'KEY1'}="VALUE";
$hash{'SUBKEY1'}{'KEY2'}="VALUE";
$hash{'SUBKEY1'}{'KEY3'}="VALUE";
$hash{'SUBKEY1'}{'KEY4'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY1'}{'KEY1'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY1'}{'KEY2'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY1'}{'KEY3'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY1'}{'KEY4'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY2'}{'KEY4'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY3'}{'KEY4'}="VALUE";
$hash{'SUBKEY1'}{'SUBSUBKEY4'}{'KEY4'}="VALUE";
$hash{'SUBKEY2'}{'KEY1'}="VALUE";
$hash{'SUBKEY2'}{'KEY2'}="VALUE";
$hash{'SUBKEY2'}{'KEY3'}="VALUE";
$hash{'SUBKEY2'}{'KEY4'}="VALUE";
print Dumper(\%hash);
$top = new MainWindow;
$top->minsize( qw(300 300));
$men = $top->Frame( )->pack(-side=>"top",-fill=>"x");
$men->Button(-text=>"Dump",-command=>\&dumper)->pack();
test(\%hash);
MainLoop();
sub dumper{
print Dumper(\%hash);
}
sub test{
my $fr = $men->Frame(-relief=>"ridge",-borderwidth=>"2")->pack(-side=>"top",-anchor=>"w",-padx=>"10");
out(\%hash,$fr);
}
sub out{
# print "OUT\n";
my $ref = shift;
my $parent = shift;
my $top = $parent->Frame()->pack(-side=>"top",-padx=>"10",-padx=>"4");
my $left = $top->Frame()->pack(-side=>"left",-padx=>"10",-padx=>"4");
my $mid = $top->Frame()->pack(-side=>"left",-padx=>"10",-padx=>"4");
foreach$key ( sort keys %{$ref}){
my $fr = $parent->Frame(-relief=>"ridge",-borderwidth=>"2")->pack(-side=>"top",-anchor=>"w",-padx=>"10");
if (ref $ref->{$key}eq "HASH"){
$fr->Label(-text=>$key)->pack(-side=>"top",-anchor=>"w");
out($ref->{$key},$fr);
}
if(!ref($ref->{$key}) ) {
$left->Label(-text=>$key)->pack(-side=>"top",-anchor=>"w");
$mid->Entry(-text=>$ref->{$key}, -validatecommand=>\&val,-validate=>"focus")->pack();
}
}
}
1
2
print&f(($_=(3x3)."3+33")=~s=3(?![^3]|$)=&f=eg);
sub f{eval(@_?$_:"'$&+'x3");}
1
2
3
4
my %hash = (
key1 => { key1_1 => 'val1_1', key1_2 => 'val1_2' },
key2 => { key2_1 => 'val2_1', key2_2 => 'val2_2' },
);
1
2
print&f(($_=(3x3)."3+33")=~s=3(?![^3]|$)=&f=eg);
sub f{eval(@_?$_:"'$&+'x3");}
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
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Data::Dumper;
# Test-HoH
my %HoH = (
EbeneEinsText => 'Text auf Ebene 1',
EbeneEinsH => {
EbeneZweiZahl => 22,
EbeneZweiH => {
EbeneDreiZahl => 42,
EbeneDreiText => '3. Ebenentext',
},
},
EbeneEinsText2 => 'Noch ein Text auf E1',
);
print Dumper \%HoH; # vorher
my $Mw = MainWindow->new();
hwids($Mw, \%HoH);
$Mw->Button(-text => 'Exit', -command => sub{ print Dumper \%HoH; # nachher
Tk::exit() })->pack;
MainLoop;
sub hwids {
my ($parent, $hashp) = @_;
for (sort keys %$hashp) {
if (ref $hashp->{$_}) {
if (ref $hashp->{$_} eq 'HASH') {
my $newframe = $parent->Frame (-borderwidth => 1, -relief => 'sunken')
->pack(-padx => 20, -anchor => 'w');
hwids($newframe, $hashp->{$_});
} else {
die "Bummer: Hash member $_ is a " . ref($hashp->{$_});
}
} else {
$parent->Label (-text => $_)->pack(-anchor => 'w');
$parent->Entry (-textvariable => \$hashp->{$_})->pack(-anchor => 'w');
}
}
}
|< 1 2 >| | 13 Einträge, 2 Seiten |