Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions lib/File/GlobMapper.pm
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ sub _parseOutputGlob
}

my $noPreBS = '(?<!\\\)' ; # no preceding backslash
my $noPreESC = '(?<![${BEGIN_DELIM}])' ; # no preceding backslash

# escape any use of the delimiter symbols
# $string =~ s/(${BEGIN_DELIM}|${END_DELIM}|${BACKSLASH_ESC})/$1$1/g;
Expand All @@ -325,7 +324,7 @@ sub _parseOutputGlob
$string =~ s/\\\*/${STAR_ESC}/g;

# Transform "#3" to BEGIN_DELIM 3 END_DELIM
$string =~ s/${noPreESC}#(\d)/${BEGIN_DELIM}${1}${END_DELIM}/g;
$string =~ s/#(\d)/${BEGIN_DELIM}${1}${END_DELIM}/g;

$string =~ s#\*#${BEGIN_DELIM}${END_DELIM}#g;

Expand All @@ -351,20 +350,18 @@ sub _getFiles
my $outFile = $inFile ;
my @matches ;

my $noPreESC = '(?<![${BEGIN_DELIM}])' ; # no preceding backslash

if (@matches = ($inFile =~ m/$self->{InputPattern}/ ))
{
$outFile = $self->{OutputPattern};
my $ix = 1;

# get the filename glob
$outFile =~ s/${noPreESC}${BEGIN_DELIM}${END_DELIM}/$inFile/g;
$outFile =~ s/${BEGIN_DELIM}${END_DELIM}/$inFile/g;

# now each of the #1, #2,...
for my $pattern (@matches)
{
$outFile =~ s/${noPreESC}${BEGIN_DELIM}${ix}${END_DELIM}/$pattern/g;
$outFile =~ s/${BEGIN_DELIM}${ix}${END_DELIM}/$pattern/g;

++ $ix;
}
Expand Down
20 changes: 19 additions & 1 deletion t/globmapper.t
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Perl $]" )
$extra = 1
if eval { require Test::NoWarnings ; Test::NoWarnings->import; 1 };

plan tests => 76 + $extra ;
plan tests => 80 + $extra ;

use_ok('File::GlobMapper') ;
}
Expand Down Expand Up @@ -340,6 +340,24 @@ Perl $]" )
], " got mapping";
}

{
title "check wildcard references after ordinary letters";

my $tmpDir ;#= 'td';
my $lex = LexDir->new( $tmpDir );

touch map { "$tmpDir/$_.tmp" } qw( abc ) ;

my $map = File::GlobMapper::globmap("$tmpDir/a*.tmp", "$tmpDir/B#1.out");
ok $map, " got map"
or diag $File::GlobMapper::Error ;

is @{ $map }, 1, " returned 1 map";
is_deeply $map,
[ [map { "$tmpDir/$_" } ("abc.tmp", "Bbc.out")],
], " got mapping";
}

# TODO
# test each of the wildcard metacharacters can be mapped to the output filename
#
Expand Down
Loading