in reply to Re^5: File::Spec::Win32 returning different result than File::Spec when doing catfile with empty string
in thread File::Spec::Win32 returning different result than File::Spec when doing catfile with empty string
Fun...
Not fun, broken design.
does $File::Spec::ISA[0] eq 'File::Spec::Unix' work reliably, then?
Have a look at the source code:
package File::Spec; use strict; our $VERSION = '3.75'; $VERSION =~ tr/_//d; my %module = ( MSWin32 => 'Win32', os2 => 'OS2', VMS => 'VMS', NetWare => 'Win32', # Yes, File::Spec::Win32 works on Ne +tWare. symbian => 'Win32', # Yes, File::Spec::Win32 works on sy +mbian. dos => 'OS2', # Yes, File::Spec::OS2 works on DJGP +P. cygwin => 'Cygwin', amigaos => 'AmigaOS'); my $module = $module{$^O} || 'Unix'; require "File/Spec/$module.pm"; our @ISA = ("File::Spec::$module"); 1;
On all operating systems not listed in %module, File::Spec will inherit from File::Spec::Unix.
Should be right very often. But are all non-Unix operating systems perl runs on listed in %modules? If not, File::Spec is even more broken than I tought.
If you run Cygwin, you should be able to use case sensitive Unix-style paths. But if you run Cygwin, File::Spec will inherit from File::Spec::Cygwin (which inherits from File::Spec::Unix). At this point, $File::Spec::ISA[0] ne 'File::Spec::Unix'. Fail.
And exactly at this point, it depends on the path that you use if the path is case sensitive or not. See File::Spec->case_tolerant() is broken, especially the Cygwin part.
Apart from that, you should not mess with other modules' interna. Perl will let you do that, but you should not:
Perl does not enforce private and public parts of its modules as you may have been used to in other languages like C++, Ada, or Modula-17. Perl doesn't have an infatuation with enforced privacy. It would prefer that you stayed out of its living room because you weren't invited, not because it has a shotgun.
The module and its user have a contract, part of which is common law, and part of which is "written". Part of the common law contract is that a module doesn't pollute any namespace it wasn't asked to. The written contract for the module (A.K.A. documentation) may make other provisions. But then you know when you use RedefineTheWorld that you're redefining the world and willing to take the consequences.
Alexander
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: File::Spec::Win32 returning different result than File::Spec when doing catfile with empty string
by jcb (Parson) on Sep 09, 2019 at 23:06 UTC | |
|
Re^7: File::Spec::Win32 returning different result than File::Spec when doing catfile with empty string
by jcb (Parson) on Sep 11, 2019 at 03:18 UTC | |
|
Re^7: File::Spec::Win32 returning different result than File::Spec when doing catfile with empty string
by Your Mother (Archbishop) on Sep 09, 2019 at 20:05 UTC |