zzspectrez has asked for the wisdom of the Perl Monks concerning the following question:
In this node it was mentioned to me that the following code I wrote:
Will needlessly ignore filenames named "..\n". This would be obviously true, since I am matching the end with $ that matches the end of a string before a newline. So to fix this I believe changing the code to:
should fix it by matching at the end of the string.
However, where exactly would this be a bug?? This would only be a bug on systems that support a newline in the filename. On windows, ( only system I have access to at the moment ) this is not an issue. You cannot create a filename with a "\n" within it.
use strict; use warnings; my $filename1 = "ap\ndd"; my $filename2 = "..\n"; open (OUT, '>', $filename1) or die "Error opening file [$filename] for write: $! -- $^E\n"; print OUT "TEST\n\nTEST\n"; close(OUT) or die "Error closing file [$filename]: $!\n";
Either filename will give an error:
. So at least in windows this would not be a bug, since you would never encounter such a filename.C:\src\re\test.pl Error opening file [.. ] for write: Invalid argument -- The filename, directory name, or volu +me label syntax is incorrect
Are there many systems that support such filenames?? I just can't see this being encountered often..
Am I missing something here??
zzSPECTREz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Filenames named "..\n" (unix)
by tye (Sage) on Aug 02, 2005 at 05:50 UTC | |
by zzspectrez (Hermit) on Aug 02, 2005 at 06:01 UTC | |
by tye (Sage) on Aug 02, 2005 at 06:07 UTC | |
by zzspectrez (Hermit) on Aug 02, 2005 at 06:09 UTC | |
by Anonymous Monk on Aug 02, 2005 at 08:31 UTC | |
by Anonymous Monk on Aug 02, 2005 at 08:29 UTC | |
by diotalevi (Canon) on Aug 02, 2005 at 17:44 UTC | |
|
Re: Filenames named "..\n"
by Anonymous Monk on Aug 02, 2005 at 08:41 UTC | |
|
Re: Filenames named "..\n"
by spiritway (Vicar) on Aug 02, 2005 at 07:26 UTC | |
|
Re: Filenames named "..\n"
by Anonymous Monk on Aug 02, 2005 at 08:35 UTC |