tags:

views:

46

answers:

3

The following is pretty well copied from the documentation.

    use File::GlobMapper qw( globmap );

    for my $pair (globmap '<*.tar.gz>' => '<#1.tgz>' )
     {
     }

And it gives

    String found where operator expected at globmapper_test1.pl line 4, near "globmap '<*.tar.gz>'"
            (Do you need to predeclare globmap?)

(Using ActivePerl 5.10.0 on Windows)

Side questions - if GlobMapper only exports one function, why is it set so you have to export it explicitly?

+1  A: 

I have never used File::GlobMapper, but I dowloaded it from CPAN just now, and I reproduced your message. One way around this issue is to use a fully-qualified call to the globmap function. Give something like this a try:

use File::GlobMapper; 

for my $pair (File::GlobMapper::globmap('<*.tar.gz>' => '<#1.tgz>')) 
 { 
 } 

It appears that the POD does not show the correct way to use the code. You can submit a bug report on CPAN. It would be best if you included a patch for the POD.

Looking at the source code for GlobMapper.pm, it seems like it does not actually use the Exporter module. This would explain the error message. I don't think the code can export any functions.

toolic
+3  A: 

It's a bug in File::GlobMapper. It sets up the @EXPORT_OK variable, but doesn't actually use Exporter.

But it gets worse. globmap doesn't return a list of arrayrefs (as claimed in the documentation). It really returns an arrayref of arrayrefs. So you'd really have to write:

use File::GlobMapper; 

for my $pair (@{ File::GlobMapper::globmap('<*.tar.gz>' => '<#1.tgz>') }) { 
  my ($from, $to) = @$pair;
} 
cjm
Thanks for that. Explains why I was hitting a brickwall.
justintime
+1  A: 

For your side question: it doesn't matter how many subroutine names you want to export. It's a good idea to not implicitly import so you don't stomp on anything that the calling file has already done.

brian d foy