while (args here) { $new_dir = code to figure out correct path... $file = code to determine file to work on... $ENV{'PATH'} .= ":/home/mysite/documents/daily/$new_dir"; system("gzip $file") == 0 or die "can't gzip file"; $ENV{'PATH'} = gets reset to original path here. }