use strict; use warnings; use File::Find qw(find); #Use File::Find module #no warnings 'File::Find'; #This turns off the warnings for File::Find e.g. Folder access issues. our $drive = $ARGV[0]; if(!defined $ARGV[0]){ print "No drive letter Specified!\n"; exit; } #*****************SET Variables************************ our $drivepath = $drive; our @drivelisting=(); #Initialise the array #******************************************************* find(\&all, $drivepath); foreach my $p (@drivelisting) #For each line (file/folder found) $p in the array @drivelisting { print "$p\n"; #Print each line in the array to screen } sub all {#Sub routine for File::Find. on all locations my $fn = $File::Find::name; push @drivelisting, $fn if($fn ne "$drive"); }