Uri Guttman wrote:
>>>>> "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

Yes, definitely better to set $/ to undef.

I'm still trying to get a handle on the libraries at my disposal -- There's so much in CPAN it's hard to know where to start. Is it equivalently efficient to use IO::All or IO::Simple, or is File::Slurp truly the best for this purpose?

I ask because I played with IO:All to read files, enjoyed the simple, intuitive syntax " my $filecontents < io('filename'); ", but (perhaps naively) assumed the native "open my $fh" to be faster since it doesn't require a "use" to load a library.


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

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

Yeah, I know, I don't need it... being verbose (sometimes) keeps a newbie like me from making silly mistakes :-)

My initial experimentation with Perl has been mostly in a line-by-line mind-set because I have a tendency to write scripts that are used like:
some-unix-command | perl -wne 'do some processing' > myresults.txt

I'm trying to expand my horizons, thanks for help,

Brian


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