On Tue, 8 Aug 2000 16:32:26 -0500, Jonathan Scott Duff wrote:

>I sincerely hope you really mean "Let's make ``open() or die''
>optional"  Exceptions should be integrated into the language but Ye
>Olde "returns undef on error" should still be available as well.
>
>
>       try { $fh = open("foo") } catch { die "Oops" }  # pick your syntax
>       $fh = open("foo") or die "Oops";

You may hope all you want. But what I gathered, and what I liked a lot,
was the idea that:

        use Fatal;
        $fh = open("foo.txt");

would act pretty much as if you had written:

        $fh = open("foo.txt") or die "Can't open file \"foo.txt\": $!";

but for every file you open. Writing all those "do or die"'s get pretty
tiresome after a while.

If you don't want a failed open() to be fatal, you could do:

        use Fatal;      # maybe the default, in, say, perl7?
        {
            no Fatal;
            $fh = open("foo.txt");
        }

or in an eval BLOCK, for all I care.

-- 
        Bart.

Reply via email to