----- Original Message -----
From: "Brian Ingerson" <[EMAIL PROTECTED]>
To: "Sisyphus" <[EMAIL PROTECTED]>
Cc: "Inline Mailing List" <[EMAIL PROTECTED]>
Sent: Wednesday, October 23, 2002 5:00 PM
Subject: Re: Hmmm:Inline-0.44/Inline::C v5.6.1 - solved ?


> On 23/10/02 13:13 +1000, Sisyphus wrote:
> >
> > ----- Original Message -----
> > From: "Brian Ingerson" <[EMAIL PROTECTED]>
> > To: "Sisyphus" <[EMAIL PROTECTED]>
> > Cc: "Inline Mailing List" <[EMAIL PROTECTED]>
> > Sent: Wednesday, October 23, 2002 11:04 AM
> > Subject: Re: Hmmm:Inline-0.44/Inline::C v5.6.1 - solved ?
> >
> >
> > > On 23/10/02 09:37 +1000, Sisyphus wrote:
> > > > Ok ... my problem vanishes if I do the following:
> > > >
> > > >     $realname =~ s/\\/\//; # change '\' to '/'
> > > >      # a few lines further on:
> > > >       $realname =~ s/\//\\/g; #change '/' to '\'
> > > >     File::Spec->catfile(@endparts) eq $realname
> > > >       or croak M28_error_grokking_path($realpath);
> > >
> > > Great. Could you send me a patch file. Just run (using cygwin):
> > >
> > >     diff -u Inline.pm.orig Inline.pm.fixed > patch
> > >
> >
> > That could take a while ... I think I have the patch utility here
somewhere,
> > but I've never used it, and have never written a patch.
> >
> > Basically we can insert '$realname =~ s/\\/\//g;' immediately above
> >     'my $realpath = $INC{$realname}
> >        or croak M27_module_not_indexed($realname);'
> >
> > and insert '$realname =~ s/\//\\/g;' immediately above
> > '     File::Spec->catfile(@endparts) eq $realname
> >        or croak M28_error_grokking_path($realpath);'
>
> Upon closer inspection, your patch seems not to make sense. Why the second
> substitution? $realname is not changed between substitutions. I'm guessing
> you were fooled into doing this because you forgot the 'g' modifier on the
> first substitution.
>
> Can you confirm this for me?
>
> Cheers, Brian
>

The %INC key eq "Math/Simple.pm"
$realname eq "Math\Simple.pm"

So, if I don't run the first regex, $INC($realname) doesn't exist, $realpath
is therefore null, and the thing croaks.

Then File::Spec->catfile takes @endparts ( = qw(Math Simple.pm)) and
converts that into "Math\Simple.pm".

So then I have to run the second regex on $realname in order that
File::Spec->catfile(@endparts) eq $realname.

A better alternative would be to make it so that %INC contained backslashes
rather than forward slashes. Then none of my regexes would be required at
all. (I guess that could be achieved with a regex in a foreach loop, if
there's no simpler means of doing it.)

As regards the 'g' switch, it would only be needed if I were building a
module such as 'Math::Simple::Basic' (where there is going to be more than
one slash in $realname, and more than 2 elements in @endparts.) If you went
with the regex method as a general fix, then you would include the 'g'.

Cheers,
Rob

Reply via email to