Forenindex » Archiv » Perl und CGI » Global symbol requires explicit package name

Global symbol requires explicit package name

Anonym
Beiträge gesamt: 22827

26. Jul 2004, 20:43
Bewertung:

gelesen: 1759

Beitrag als Lesezeichen
Kann mir jemand mit diesem script helfen???
Ich bin schon langsam am verzweifeln......

#!/usr/bin/perl -w

use strict;
use CGI::Carp qw(fatalsToBrowser);


@Array=("string1",
"string2",
"string3",
"string4",
"string5");



fisher_yates_shuffle(\@Array);

if (open (FH, ">test.txt")){;
foreach (@Array){
print FH "$_\n";
}
close FH;
}

# fisher_yates_shuffle( \@array ) : generate a random permutation
# of @array in place
sub fisher_yates_shuffle {
my $array = shift;
my $i;
for ($i = @$array; --$i; ) {
my $j = int rand ($i+1);
next if $i == $j;
@$array[$i,$j] = @$array[$j,$i];
}
}


Hier sind die Fehlermeldungen:


Global symbol "@Array" requires explicit package name at test.pl line 8.
Global symbol "@Array" requires explicit package name at test.pl line 16.
Global symbol "@Array" requires explicit package name at test.pl line 19.
Execution of test.pl aborted due to compilation errors.

Global symbol requires explicit package name

SabineP
Beiträge gesamt: 7586

27. Jul 2004, 01:10
Bewertung:

gelesen: 1759

Beitrag als Lesezeichen
Hallo Anonym,

da Du
use strict;
verwendest, schreibe

my @Array

Gruß Sabine