Closed p5pRT closed 16 years ago
This is a bug report for perl from tag@tenet.res.in\, generated with the help of perlbug 1.35 running under perl v5.8.8.
----------------------------------------------------------------- open fails if the filename ends in space. See the example code below\, which fails to open the file "fff " which exists in the current directory. Verified on Debian Linux and Mac OS X 5.1. ---------------- #!/usr/bin/perl
opendir DIR\, "."; while ($f = readdir DIR) { print "readdir: |$f| exists\n" if ($f =~ "^fff"); } closedir DIR;
$file = "fff ";
open CDFILE\, $file | die "Can not open |$file|\n";
----------------
Regards
TAG
-----------------------------------------------------------------
Timothy A. Gonsalves
Professor & Head
Dept of Computer Science & Engg
Indian Institute of Technology
Madras - 600 036\, India
Phone: +91-44-2257-4353/50 (o) -6353 (r) -4352 (fax)
E-mail: tag@tenet.res.in Web: http://www.cse.iitm.ernet.in
-----------------------------------------------------------------
On Sep 6\, 2008\, at 8:18 AM\, tag@tenet.res.in (via RT) wrote:
----------------------------------------------------------------- open fails if the filename ends in space. See the example code below\, which fails to open the file "fff " which exists in the current
directory. Verified on Debian Linux and Mac OS X 5.1. ----------------
\
open CDFILE\, $file | die "Can not open |$file|\n";
That is as documented.
$ 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:
If you want whitespace at the start of end of a file honored then you need to use the 3-argument form of open
open CDFILE\, '\<'\, $file or die "Can not open |$file|\n";perl
Graham.
The RT System itself - Status changed from 'new' to 'open'
@rgs - Status changed from 'open' to 'rejected'
Greetings:
I found the solution (by using 3 args to open()) to my problem in the perlfunc man page. This bug report may be closed as not-a-bug.
Regards TAG
Migrated from rt.perl.org#58632 (status was 'rejected')
Searchable as RT58632$