in reply to quick "open->close" file

Or if you want to perform this on an arbitrary file
use IO::File; my $line = -f $file and grep { ... } IO::File->new($file)->get_lines;
So if $file exists, create a temporary IO::File object and read its contents. Not as robust as the <> solution, but it does perform an open/read/close.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: quick "open->close" file
by esh (Pilgrim) on Aug 06, 2003 at 15:30 UTC
    Minor correction: Replace "get_lines" with "getlines".
    use IO::File;
    my $line = -f $file and grep { ... } IO::File->new($file)->getlines;