#!/usr/bin/perl -w
$n1=$ARGV[0];
$n1 =~ s/\\/\//g;
$dir=$n1;
$n1=&listing;
sub listing{
opendir(DIR, $dir) or die $!;
while (my $file = readdir(DIR)) {
# A file test to check that it is a directory
# Use -f to test for a file
next unless (-d "$dir/$file");
if($file =~ m/^[a-zA-Z]/) {
@dir_list=$file;
}
foreach $va(@dir_list){
#print $va."NEW DIR \n";
@md_dir=$va;
}
add_path(@md_dir);
}
closedir(DIR);
}
sub add_path(@md_dir) {
foreach $vm(@md_dir) {
$p=$n1."/$vm";
}
@mydir=$p;
add_infor(@mydir);
}
sub add_infor(@mydir) {
foreach $myfil(@mydir) {
print $myfil;
print "\n";
opendir(DIR,$myfil)||die("cannot open");
}
}
是我的代碼....在那裏我通過命令行的路徑....我得到的目錄列表.....我追加到orignal路徑來打開列出目錄.. 但錯誤是perl:路徑構建
Use of uninitialized value in print at 1.pl line 47.
Use of uninitialized value in opendir at 1.pl line 49.
cannot open at 1.pl line 49.
什麼是線47 49?你想做什麼 ?嚴格使用;使用警告; ... – Toto 2011-01-05 08:56:22