#!/usr/bin/perl -w use strict; open(FILE,'/path/to/file') || die $!; print while (); close(FILE); ... open(FILE2,'/path/to/file2') || die $!; print while (); close(FILE2);