This could look about like the following piece of code:
#! /usr/bin/perl use warnings; use strict; my $file = shift(@ARGV); unless( defined $file or -f $file ) { die "Usage: $0 filename\n"; } # unless open( my $FH, "<", $file ) or die "Error: couldn't open file '$file': $!\n"; while( defined my $line = <$FH> ) { chomp $line; if( $line =~ /something/ ) { print "Line found in $.: $line\n"; last; } # if } # while close( $FH );
Best regards,
perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"
In reply to Re: Exit a program if there are any matching lines?
by strat
in thread Exit a program if there are any matching lines?
by sdslrn123
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |