>>>>> "BFY" == Brian F Yulga <byu...@langly.dyndns.org> writes:

  BFY> My apologies if I'm beating a dead horse here, but I'm new to Perl and 
  BFY> thought of a slightly different approach:


  BFY> my $searchrx = qr/whatever/;  # or q/whatever/ if you don't need regexp
  BFY> @ARGV or die qq/you didn't specify a filename\n/;
  BFY> open FH, q/</, shift @ARGV or die qq/file open error: $!/;
  BFY> $_ = join q//, <FH>;

that is very slow and clunky. perl could slurp the file for you if you
set $/ to undef. or better yet, use File::Slurp to do it

  BFY> close FH;
  BFY> if ( ! m/$searchrx/s ) {

why are you using m//? the m isn't needed if you use // for delimiters

the OP wants to know if a file has something or not, not to print each
line.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to