Hellhound4 has asked for the wisdom of the Perl Monks concerning the following question:
Gives this error ""my" variable @file masks earlier declaration in same scope at /root/begperl/DirectorySearch.plx line 20" I understand what the error means but "my @file" only appears 2x in the program. There are several more like this. Full code below.my $directory = File::Spec->catfile(my @path, my $directoryTest); opendir DIR,my $directory or die "cannot open dir $directory: $!"; my @file= readdir DIR; my @FinalDirectoryList; push (my @FinalDirectoryList,my @file);
#!/usr/bin/perl use strict; use warnings; use File::Spec::Functions; print "First Box in Disk?\n"; my $firstBox = <stdin>; print "Last Box in Disk?\n"; my $lastBox = <stdin>; print "Pick Directory\n"; my $directoryTest = <stdin>; my @path="/root/begperl/TestDirectory/"; my $directory = File::Spec->catfile(my @path, my $directoryTest); opendir DIR,my $directory or die "cannot open dir $directory: $!"; my @file= readdir DIR; my @FinalDirectoryList; push (my @FinalDirectoryList,my @file); foreach my $file (@file) {print "$file\n";} close FileNameList; #close the file. closedir DIR; #close directory
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Errors
by toolic (Bishop) on Mar 27, 2012 at 20:01 UTC | |
by Hellhound4 (Novice) on Mar 27, 2012 at 20:09 UTC | |
by CountZero (Bishop) on Mar 27, 2012 at 20:15 UTC | |
by Hellhound4 (Novice) on Mar 27, 2012 at 20:47 UTC | |
by ww (Archbishop) on Mar 27, 2012 at 21:23 UTC | |
by CountZero (Bishop) on Mar 27, 2012 at 21:23 UTC | |
| |
by roboticus (Chancellor) on Mar 27, 2012 at 20:15 UTC |