Thread Innerhalb Hash Def auf Keys zugreifen (42 answers)
Opened by bianca at 2013-09-08 06:08

bianca
 2013-09-08 06:08
#169985 #169985
User since
2009-09-13
7016 Artikel
BenutzerIn

user image
Guten Morgen!
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
my %test = (
    foo     => 'bar',
    test    => $test{foo},
);
print "'$test{test}'\n";

Quote
Global symbol "%test" requires explicit package name at test.pl line 7.
Execution of test.pl aborted due to compilation errors (#1)
(F) You've said "use strict" or "use strict vars", which indicates
that all variables must either be lexically scoped (using "my" or "state"),
declared beforehand using "our", or explicitly qualified to say
which package the global variable is in (using "::").

Uncaught exception from user code:
Global symbol "%test" requires explicit package name at test.pl line 7.
Execution of test.pl aborted due to compilation errors.
at test.pl line 9.

Gibt es eine Syntax, innerhalb der Hash Definition auf andere Keys zuzugreifen, sodass ich hier ohne Fehlermeldung eine Zuweisung von 'bar' an den Key 'test' erreiche?
10 print "Hallo"
20 goto 10

View full thread Innerhalb Hash Def auf Keys zugreifen