#!/usr/bin/perl use strict; use warnings; my $file = 'whiletest.txt'; open(my $fh,"<",$file) or die $!; for(0..3){ while(my $line = <$fh>){ print $line; } seek $fh,0,0; } close $fh;