1. Get list of all files in '/var/log/cr_user' 2. Foreach file in list 3. read file contents and process each line of CSV text 4. close and then delete the file 5. Exit #### use strict; use warnings; my $path='/var/log/cr_user'; # =shift @ARGV; # is better IMO # clear @ARGV of junk so we can use <> for file IO @ARGV=(); #get the files my @files=glob "$path/*"; # as long as there are still files while (@files) { #remove the first file from list and store it my $to_delete=shift @files; # stick the file in @ARGV so <> can do its ting. push @ARGV,$to_delete; # iterate over the lines in the file while (<>) { # lose newline chomp; # split the line by ',' my @vars=split/,/; # print the results print join(" ",@vars),"\n"; } # delete the file unlink $delete; } #and fall of the end of the script "gracefully exit :-)"