foreach $_(@ARGV) { my $rename = $_; if (!-e $rename) { warn "$rename does not exist"; # previously I had this as die but obviously that killed the program and did not continue with the correct argument for(my $i=0;$i<$rename;$i++){ # I am not really sure if this loop is the right idea #or what to put in it.. }