Writing to a file is covered in perlintro.
In reply to Re^5: partial matching of lines in perl by hippo in thread partial matching of lines in perl by Sidd@786