use Cwd; my $dir = getcwd; mkdir("$dir/output", 0777); open (my $fh, "<","$dir/data/file.txt") or die ("$!"); open(my $ofh, ">", $dir/output/outfile.txt) or die("$!"); while(my $line = <$fh>){ #do stuff such as process load into a data structure, regex #write to $ofh } ####