Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Exit a program if there are any matching lines?

by strat (Canon)
on Jun 27, 2006 at 09:03 UTC ( #557738=note: print w/replies, xml ) Need Help??

in reply to Exit a program if there are any matching lines?

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."

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://557738]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2017-01-16 20:08 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.