develooper Front page | perl.perl5.porters | Postings from May 2008

[perl #54728] PathTools-3.27 triggers a bug in Perl

Thread Next
From:
Jan Dubois
Date:
May 23, 2008 15:23
Subject:
[perl #54728] PathTools-3.27 triggers a bug in Perl
Message ID:
rt-3.6.HEAD-11257-1211565672-608.54728-75-0@perl.org
# New Ticket Created by  Jan Dubois 
# Please include the string:  [perl #54728]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=54728 >


The update to PathTools-3.27 triggers a bug in the localization of $1:

#!perl
use File::Spec::Win32 ();

print File::Spec::Win32->catfile("c:/foo", "bar"), "\n";
"bar" =~ m/(.*)/;
print File::Spec::Win32->catfile("c:/foo", $1), "\n";
"bar" =~ m/(.*)/;
print File::Spec::Win32->catfile("c:/foo", "$1"), "\n";
__END__

With PathTools-3.27:
C:\foo\bar
C:\foo\c:
C:\foo\bar

With older version of PathTools:
C:\foo\bar
C:\foo\bar
C:\foo\bar

The problem seems to be that $1 isn't properly localized.  A simple
workaround in File::Spec::Win32 is to stringify @_ in _canon_cat(),
e.g.

sub _canon_cat(@)
{
    @_ = map "$_", @_;
    my $first  = shift;

But it would be nicer if the problem can be solved in a more general
manner.

I encountered this problem when I was testing Pod::Simple with
5.8.9-tobe, which contains this code triggering the problem
in Pod::Simple::HTMLBatch:

    if( ref($chunk->[-1]) and $url =~ m{^(_[-a-z0-9_]+\.css$)} ) {
      $outfile = $self->filespecsys->catfile( $outdir, $1 );

Cheers,
-Jan


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About