Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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


Comment on Re: Exit a program if there are any matching lines?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://557738]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2014-09-18 01:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (103 votes), past polls