#! /usr/bin/perl -w

#  scr07C.pl 
#  How to use different folder(directory) location files?           
#  Carefully include the PATH (absolute or relative) with the filename. 
#  In the sample below, infile.txt locates in /home/user_name/bin/  folder.    
#  While, outfile.txt requires a new folder "RESULT" at this current directory.
# 


mkdir("RESULT", 0777);                             ##  Make a folder in the current directory for preparation.

open (IN,  "/home/user_name/bin/infile.txt");      ##  Specify reading filename location absolutely
open (OUT, "> RESULT/outfile.txt");                ##  Specify writing-out filename location relatively 

while(<IN>){              

     print $_;              ###   For screen monitor
     print OUT $_;          ###   Echo writing down into outfile.txt by FileHandle OUT.

}
close(IN);
close(OUT);