#!/usr/bin/perl

use warnings;
use strict;

# Make sure we got a valid file in $ARGV[0]
die "Wrong usage\n" unless (defined $ARGV[0] and -f $ARGV[0]);

open my $FH, "< $ARGV[0]" or die "Can't open $ARGV[0] : $!\n"; # I
think it was #!...

my $count = 0;
my $linesPrinted = 0;
while (<$FH>) { # Count lines with this string and print the 6th line
with this string
   $count++ if ( /puts$conCheckFail/);
   if ( $count <= 6 and $linesPrinted <= 6 ) {
      $linesPrinted++; # Count lines printed. Stop after 6
      print;
   }
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to