Tom Christiansen wrote:
>
> >Except that you can test for failure by checking to see if $fh is defined.
>
> Let your true be true and your false be false.
>
> open($fh, "<", $filename) || die;
>
> --tom
Not sure I agree with that. I think one point of confusion / perceived
difference between filehandles, open(), and basically every other
builtin is that all the others *return* what you want. For ex, you call
grep as:
(@results) = grep /^$/, @file;
It would be pretty strange to call it as:
grep @results, /^$/, @file;
But that's just what open() does! It says "put the handle variable you
want to modify here, and I'll screw with its value if I can open this
file". I'd rather it be more consistent, instead saying "give me the
file you want to open, and I'll return a handle or undef". This seems
more Perl-consistent to me:
@results = grep /^$/, @file;
($first) = split ':', $line;
$handle = open $filename;
$object = new Class;
Since we're ripping Perl 6 apart, and one thing I've heard widely
mentioned is internal consistency, this seems to me to be worth
considering. Not sure if it's RFC-worthy in its own right or not, but I
can see many benefits from this approach. Unless I'm missing something,
I don't see the benefit of a "strictly true" return code, unless you're
doing something like this:
die unless (open($fh, "<$filename") == 1);
In which case egads!
-Nate