in reply to Re^4: true from (-e "") on Windoze (" is an illegal filename character
in thread true from (-e "") on Windoze
It's an invalid file name, so it should return an error indicating such.
Not so.
When you type "" on the command line, the program never sees the "s as they are processed by the command line processor. What the program receives is an empty string.
In a very (perlish) pragmatic manner, the OS chooses to use what would otherwise be a nonsensical value -- to which even an error message of "Illegal filename" would be wrong, because strictly, they haven't supplied any file name -- to have a meta meaning and utilises it.
In this case, it would be nonsensical to dir/stat files matching 'nothing', so it ascribes that value the meta meaning -- a default value -- of 'everything'.(*)
That is no different to many perl built-ins using $_ if they receive no parameters. Or *nix taking a bare ls to mean everything. (The fact that they issue an "No such file or directory" message to ls '' is both strictly wrong; and missing a trick.)
Pure pragmatism of the kind that Perl does so well.
Whilst I could understand -- but disagree with -- a Java programmer saying yuck to such pragmatism, it strikes me as disjoint coming from a Perl aficionado like you.
* It is even logical at the CS level, in that, the empty string is a vaild substring of every possible string.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: true from (-e "") on Windoze (" is an illegal filename character
by ikegami (Patriarch) on Sep 17, 2012 at 18:12 UTC | |
by BrowserUk (Patriarch) on Sep 17, 2012 at 20:06 UTC | |
by ikegami (Patriarch) on Sep 17, 2012 at 23:06 UTC | |
by BrowserUk (Patriarch) on Sep 18, 2012 at 02:32 UTC | |
by ikegami (Patriarch) on Sep 19, 2012 at 23:05 UTC | |
|