#!/usr/bin/perl my $x=0;open(OF, ">OUT.txt");open(IF, "){if(/$ARGV[1]/){print OF "$_" if $x < $ARGV[0];$x++}} close IF;close OF;