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
In reply to Perl Errors by Hellhound4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |