in reply to How do I call a DOS command with a /C variable in PERL ?
Calling out to find (which is the rough equivalent of fgrep, IMSMR) is kinda pointless. Just open the file and search for the text yourself. This is perl you know.
sub log_has_ip { my( $logfile, $ip ) = @_; $ip = qr/$ip/; open( my $lfh, $logfile ) or die "Can't open $logfile: $!\n"; while( <$lfh> ) { return 1 if /$ip/; } return }
Update: Just looked again and noticed it appears that you're trying to get output from system, which means you probably would want qx// or ``. That is, aside from the fact that you really don't need to call an external program to begin with.
instead of system
|
|---|