Re: Perl 5.8.6 bug in open()?
- From: jeggen@xxxxxxxxx (Jeff Eggen)
- Date: Tue, 30 Oct 2007 08:01:19 -0600
<snip><google@xxxxxxxxx> 10/30/2007 6:33 AM >>>
Can't open 'file_test ': No such file or directory at testopen.pl line
42.
# -- <the question> ---
Is this a known bug in Perl 5.8.6?
No, it's a documented feature of the open call. See perldoc -f open:
The filename passed to 2-argument (or 1-argument)
form of open() will have leading and trailing
whitespace deleted, and the normal redirection
characters honored. This property, known as "magic
open", can often be used to good effect. A user
could specify a filename of "rsh cat file |", or you
could change certain filenames as needed:
$filename =~ s/(.*\.gz)\s*$/gzip -dc < $1|/;
open(FH, $filename) or die "Can't open $filename: $!";
Use 3-argument form to open a file with arbitrary
weird characters in it,
open(FOO, '<', $file);
otherwise it's necessary to protect any leading and
trailing whitespace:
$file =~ s#^(\s)#./$1#;
open(FOO, "< $file\0");
Change your open call to use the three argument version and you should be fine.
Hope this helps,
Jeff Eggen
IT Analyst
Saskatchewan Government Insurance
Ph (306) 751-1795
email jeggen@xxxxxxxxx
This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the named addressee, please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that using, disclosing, copying or distributing the contents of this information is strictly prohibited.
.
- References:
- Perl 5.8.6 bug in open()?
- From: google
- Perl 5.8.6 bug in open()?
- Prev by Date: Re: Perl 5.8.6 bug in open()?
- Next by Date: RE: Hash Variables
- Previous by thread: Re: Perl 5.8.6 bug in open()?
- Next by thread: Re: Perl 5.8.6 bug in open()?
- Index(es):
Relevant Pages
|