in reply to Re: open my $fh, MODE, FILE vs. open my $fh, "MODE FILE"
in thread open my $fh, MODE, FILE vs. open my $fh, "MODE FILE"

There's more to it. Whitespace on both sides of the filename gets stripped. Tough luck if your filename actually has whitespace on either end of its name...

From perldoc -f open:

The filename passed to open will have leading and trailing whitespace deleted, and the normal redirection characters honored.
  • Comment on Re: Re: open my $fh, MODE, FILE vs. open my $fh, "MODE FILE"

Replies are listed 'Best First'.
Re: open my $fh, MODE, FILE vs. open my $fh, "MODE FILE"
by jonadab (Parson) on Feb 03, 2004 at 14:38 UTC
    Tough luck if your filename actually has whitespace on either end of its name

    If you have filenames like that, you'll have trouble with more than just Perl. Even whitespace in the middle of filenames has a tendency to break things.

    I would personally be more concerned about the backward compatibility. There are a lot of people out there still using 5.003 for one reason or another.

    Of course, if you're using newer Perl features anyway, like unicode or threads, then that consideration becomes moot and you may as well use the three-arg form.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/