MrSparks has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 use diagnostics; 6 7 my %nationality_of = ( 8 'Ovid' => 'Greek', 9 'John Davidson' => 'Scottish', 10 'Tennyson' => 'English', 11 'Poe' => 'Tracky', # Geek? 12 ); 13 14 my @nationalities = @nationality_of( 'Ovid', 'Tennyson' ); 15 print "@nationalities"; 16
This piece of simple code is not compiling for me. This is the error:
Possible unintended interpolation of @nationalities in string at test line 15 (#1)
2 (W ambiguous) You said something like '@foo' in a double-quoted string
3 but there was no array @foo in scope at the time. If you wanted a
4 literal @foo, then write it as \@foo; otherwise find out what happened
5 to the array you apparently lost track of.
6
7 Global symbol "@nationality_of" requires explicit package name at test line 14.
8 syntax error at test line 14, near "@nationality_of( "
9 Global symbol "@nationalities" requires explicit package name at test line 15.
10 Execution of test aborted due to compilation errors (#2)
11 (F) You've said "use strict" or "use strict vars", which indicates
12 that all variables must either be lexically scoped (using "my" or "state"),
13 declared beforehand using "our", or explicitly qualified to say
14 which package the global variable is in (using "::").
15
16 Uncaught exception from user code:
17 Global symbol "@nationality_of" requires explicit package name at test line 14.
18 syntax error at test line 14, near "@nationality_of( "
19 Global symbol "@nationalities" requires explicit package name at test line 15.
20 Execution of test aborted due to compilation errors.
~
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with hash slice.
by Athanasius (Archbishop) on Feb 21, 2015 at 06:08 UTC | |
|
Re: Problem with hash slice.
by roboticus (Chancellor) on Feb 21, 2015 at 06:10 UTC |