#!/usr/bin/perl
use warnings;
use strict;
my ($Filepath) = @ARGV;
sub scan_file{
? ? my @files = glob(@_[0]);
? ? foreach (@files){
? ? #-d為目錄
? ? ? ? if(-d $_){
? ? ? ? ? ? my $Filepath = "$_/*";
? ? ? ? ? ? ? ? print "Filepath=$Filepath\n";
? ? ? ? ? ? scan_file($Filepath);
? ? ? ? ? ? #-f為普通文本
? ? ? ? }elsif(-f $_){
? ? ? ? ? ? print "file $_\n";
? ? ? ? }
? ? }
}
scan_file($Filepath);
腳本
輸出