#!/usr/bin/perl my $counter; open A, 'file.txt'; while() { print if ($counter++ < 10); } close A;