This is an excerpt from the latest version perlfaq5.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at
http://faq.perl.org .
--------------------------------------------------------------------
5.17: How can I open a file with a leading ">" or trailing blanks?
(contributed by Brian McCauley)
The special two argument form of Perl's open() function ignores trailing
blanks in filenames and infers the mode from certain leading characters
(or a trailing "|"). In older versions of Perl this was the only version
of open() and so it is prevalent in old code and books.
Unless you have a particular reason to use the two argument form you
should use the three argument form of open() which does not treat any
charcters in the filename as special.
open FILE, "<", " file "; # filename is " file "
open FILE, ">", ">file"; # filename is ">file"
--------------------------------------------------------------------