First occurance

A PERL script that prints just the first occurrence of a string in a file and immediately exits (the string and the filename are the first and the second command line arguments; I used filehandle to open an input file).

open my $fh , '<' , $ARGV[1] || die "$!";
my $occ = 1;
while (<$fh>){
        chomp ;
        if (/$ARGV[0]/){
                print "matches at line $occ\n";
                last;
        }
        $occ++;
}
close $fh;

HTH,
PL