Re: Perl 5.8.6 bug in open()?
- From: rcoops@xxxxxxxxx (Rob Coops)
- Date: Tue, 30 Oct 2007 14:54:41 +0100
Not sure but I would say it is a bug on your side. Accepting a file name
without even some basic validation. (no spaces at the beginning/end of your
file names)
This will solve the issue, open is used to open more things then just files,
therefore what it is fed is what it opens. Where -e and -f are used only for
the checking if a file exists and thus they do the removal of
preceding/trailing spaces automatically.
At least that is how I always understood that bit.
Regards,
Rob
On 10/30/07, google@xxxxxxxxx <google@xxxxxxxxx> wrote:
# --- <the program> ----
my $fname = '/volumes/hd/home/kevin/file_test '; # note file ends
with a space character
print "Exists: <$fname>\n" if (-e $fname);
print "Is a file: <$fname>\n" if (-f $fname);
open(FH, $fname) or die "Can't open '$fname': $!";
close(FH) or die "Can't close '$fname': $!";
# --- <the output> ---
Processing file: file_test
Exists: <file_test >
Is a file: <file_test >
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?
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
- References:
- Perl 5.8.6 bug in open()?
- From: google
- Perl 5.8.6 bug in open()?
- Prev by Date: Re: printf problem
- Next by Date: Re: Perl 5.8.6 bug in open()?
- Previous by thread: Perl 5.8.6 bug in open()?
- Next by thread: Re: Perl 5.8.6 bug in open()?
- Index(es):
Relevant Pages
|