Thread Frage zu Hash::Util (11 answers)
Opened by Crian at 2005-02-17 16:42

renee
 2005-02-17 17:28
#51864 #51864
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
@Crian: willst Du das hier:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#! /usr/bin/perl

use strict;
use warnings;
use Data::Dumper;
use Hash::Util qw(lock_keys);

my %hash = (test => {key => 1, kes => 2},
test2 => {key => 1, kes => 2},
);

lock_keys(%{$hash{test2}});

$hash{test}->{uhu} = 1;
print Dumper(\%hash);

$hash{test2}->{uhu} = 1;
print Dumper(\%hash);


Ausgabe:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
perl lock.pl
$VAR1 = {
'test2' => {
'kes' => 2,
'key' => 1
},
'test' => {
'uhu' => 1,
'kes' => 2,
'key' => 1
}
};
Attempt to access disallowed key 'uhu' in a restricted hash at lock.pl line 17.
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Frage zu Hash::Util