line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::Currency::Convert::Custom;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
108455
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use base qw(Finance::Currency::Convert);
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1200
|
|
6
|
1
|
|
|
1
|
|
4071
|
use LWP::UserAgent;
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
418
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.00';
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub updateRates() {
|
11
|
0
|
|
|
0
|
0
|
0
|
my $self = shift;
|
12
|
0
|
|
|
|
|
0
|
my $sub_ref = shift;
|
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
0
|
my @CurrencyList = @_;
|
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
0
|
unless(ref $sub_ref eq 'CODE'){
|
17
|
|
|
|
|
|
|
#case of not defined own sub and sent countries list as params :)
|
18
|
0
|
0
|
|
|
|
0
|
unless(ref $sub_ref){
|
19
|
0
|
|
|
|
|
0
|
push @CurrencyList, $sub_ref;
|
20
|
|
|
|
|
|
|
}
|
21
|
0
|
|
|
0
|
|
0
|
$sub_ref = sub{my ($cur_from, $cur_to) = @_; return $self->currency_finyahoo($cur_from, $cur_to);}
|
|
0
|
|
|
|
|
0
|
|
22
|
0
|
|
|
|
|
0
|
}
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
0
|
foreach my $source (@CurrencyList) {
|
26
|
0
|
|
|
|
|
0
|
foreach my $target (sort keys %{ $self->{CurrencyRates}}) {
|
|
0
|
|
|
|
|
0
|
|
27
|
0
|
|
|
|
|
0
|
$self->setRate($source, $target, &{$sub_ref}($source, $target));
|
|
0
|
|
|
|
|
0
|
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
}
|
30
|
0
|
|
|
|
|
0
|
foreach my $source (sort keys %{ $self->{CurrencyRates}}) {
|
|
0
|
|
|
|
|
0
|
|
31
|
0
|
|
|
|
|
0
|
foreach my $target (@CurrencyList) {
|
32
|
0
|
|
|
|
|
0
|
$self->setRate($source, $target, &{$sub_ref}($source, $target));
|
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
}
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub updateRate() {
|
38
|
12
|
|
|
12
|
0
|
12742
|
my $self = shift;
|
39
|
12
|
|
|
|
|
32
|
my $sub_ref = shift;
|
40
|
12
|
|
|
|
|
23
|
my $source = shift;
|
41
|
12
|
|
|
|
|
22
|
my $target = shift;
|
42
|
12
|
50
|
|
|
|
67
|
unless(ref $sub_ref eq 'CODE'){
|
43
|
|
|
|
|
|
|
#case of not defined own sub and sent countries list as params :)
|
44
|
12
|
50
|
|
|
|
41
|
unless(ref $sub_ref){
|
45
|
12
|
|
|
|
|
64
|
$target = $source;
|
46
|
12
|
|
|
|
|
16
|
$source = $sub_ref;
|
47
|
|
|
|
|
|
|
}
|
48
|
12
|
|
|
12
|
|
22
|
$sub_ref = sub{my ($cur_from, $cur_to) = @_; return $self->currency_finyahoo($cur_from, $cur_to);}
|
|
12
|
|
|
|
|
41
|
|
49
|
12
|
|
|
|
|
75
|
}
|
50
|
|
|
|
|
|
|
|
51
|
12
|
|
|
|
|
29
|
$self->setRate($source, $target, &{$sub_ref}($source, $target));
|
|
12
|
|
|
|
|
31
|
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub currency_finyahoo() {
|
61
|
|
|
|
|
|
|
|
62
|
12
|
|
|
12
|
0
|
17
|
my $self = shift;
|
63
|
|
|
|
|
|
|
#$self->{UserAgent}
|
64
|
12
|
|
|
|
|
23
|
my ($cur_from, $cur_to) = @_;
|
65
|
12
|
|
|
|
|
112
|
my $browser = LWP::UserAgent->new;
|
66
|
12
|
|
|
|
|
24081
|
my $response = $browser->get( "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=".$cur_from.$cur_to."=X" );
|
67
|
12
|
|
|
|
|
8036141
|
my $data = $response->content();
|
68
|
12
|
|
|
|
|
223
|
my @arr = split /,/,$data;
|
69
|
12
|
|
|
|
|
687
|
return $arr[1];
|
70
|
|
|
|
|
|
|
}
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1;
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
__END__
|