[Bps-public-commit] r15132 - in Class-Require/trunk: lib/Class

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 13 14:22:08 EDT 2008


Author: sartak
Date: Wed Aug 13 14:22:08 2008
New Revision: 15132

Modified:
   Class-Require/trunk/   (props changed)
   Class-Require/trunk/lib/Class/Require.pm

Log:
 r69472 at onn:  sartak | 2008-08-13 14:22:01 -0400
 Rewrite the class->file mapper to take into account different OSes


Modified: Class-Require/trunk/lib/Class/Require.pm
==============================================================================
--- Class-Require/trunk/lib/Class/Require.pm	(original)
+++ Class-Require/trunk/lib/Class/Require.pm	Wed Aug 13 14:22:08 2008
@@ -3,6 +3,7 @@
 use strict;
 use warnings;
 use base 'Exporter';
+use File::Spec;
 
 our @EXPORT_OK = qw/load_class try_load_class is_class_loaded/;
 our %EXPORT_TAGS = (
@@ -27,8 +28,12 @@
 
     return 1 if is_class_loaded($class);
 
-    my $file = $class . '.pm';
-    $file =~ s{::}{/}g;
+    # see rt.perl.org #19213
+    my @parts = split '::', $class;
+    my $file = $^O eq 'MSWin32'
+             ? join '/', @parts
+             : File::Spec->catfile(@parts);
+    $file .= '.pm';
 
     return 1 if eval {
         local $SIG{__DIE__} = 'DEFAULT';



More information about the Bps-public-commit mailing list