On Mar 2, 2011 4:47 PM, "Uri Guttman" <u...@stemsystems.com> wrote:
>
> >>>>> "sw" == shawn wilson <ag4ve...@gmail.com> writes:
>
>  sw> On Wed, Mar 2, 2011 at 3:37 PM, Uri Guttman <u...@stemsystems.com>
wrote:
>  >> >>>>> "M" == Matt  <lm7...@gmail.com> writes:
>  >>
>  >> 2 lines will do it:
>  >>
>  >> use File::Slurp ;
>  >>
>  >> unless( read_file( $file ) =~ /$whatever/ ) {
>  >>
>  >> # do something
>  >> }
>  >>
>  >>
>  >> what's better about File::Slurp than just doing:
>
>  sw> my( $file, $string ) = @argv;
>  sw> open my $fh, '<', $file;
>
>  sw> while( <$fh> ) {
>  sw>  print "found" if /$string/ ;
>  sw> }
>
> less code, much much faster. you loop over each line. my code does one
> regex call and stays inside perl for that. inside perl is usually faster
> than running perl op. use the benchmark module and look at the
> difference. it will be noticeable.
>

How can I tell or do I figure out if code 'stays inside perl' or not? And,
I'm not exactly sure what you mean by that either?

Reply via email to