The proper way to open()

Abigail abigail at
Mon Jan 30 16:49:45 GMT 2012

On Mon, Jan 30, 2012 at 04:46:00PM +0000, Roger Burton West wrote:
> What's a good way of opening a file as read-only, and failing if it
> doesn't exist? open() just returns a handle that's not obviously
> invalid, which strikes me as odd behaviour. At the moment I'm doing
> something like:
>   open IN,"<$cfg";
>   if (eof IN) {
>     die "bad config file $cfg\n";
>   }

die "Bad config file $cfg" unless open my $ih, "<", $cfg;


More information about the mailing list