#!/usr/bin/perl use strict; use warnings; my ($file, $prefix); walk("C:\\"); sub walk { $file = shift; $prefix = shift; #($file, $prefix) = @_; # You can also use shift. my $file = shift; my $prefix = shift; $prefix ||= ""; # Set $prefix to "" if undefined (first case) #print "$file\n"; if ("$file"=~m/.nsf$/){ print "Prefix: $prefix\nFile:$file\n"; # print current file. } if(-d $file) { # is this a directory? chdir $file; opendir(DIR, "."); my @files = grep {$_ !~ /^\.\.?$/} readdir(DIR); # Ignore . and .. closedir DIR; walk($_, "$prefix$file\\") foreach @files; # recursive call chdir ".."; } }