Subject: | Problem with Geo::IPfree 1.151940 |
Date: | Thu, 16 Jul 2020 19:08:04 +0200 |
To: | <bug-Geo-IPfree [...] rt.cpan.org> |
From: | "Andreas Mock" <andreas.mock [...] web.de> |
The following code shows a problem with Geo::IPfree while loading
the module dynamically with two different approaches.
Both approaches thow an exception.
--------------------------8<--------------------------
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Module::Runtime qw(require_module);;
use Class::Load qw(load_class);
# First Attempt
my @y = map {
require_module('Geo::IPfree');
} qw(1);
# Second Attempt
#my @y = map {
# load_class('Geo::IPfree');
#} qw(1);
__END__
# Problematic code in Geo/IPfree.pm
#
# Solution:
# a) Using explicit variable storing the read lines
# or
# b) localize $_
#
28 {
29 my $c = 0;
30 %baseX = map { $_ => ( $c++ ) } @baseX;
31 $base = @baseX;
32
33 my @data;
34 while ( <DATA> ) {
35 last if m{^__END__};
36 chomp;
37 push @data, split m{ }, $_, 2;
38 }
39 %countrys = @data;
40 }
--------------------------8<--------------------------
Best regards
Andreas