line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Finance::RawMaterialPrice; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
37381
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
5
|
1
|
|
|
1
|
|
681023
|
use autodie; |
|
1
|
|
|
|
|
21056
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
6989
|
use utf8; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
4
|
|
7
|
1
|
|
|
1
|
|
36
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
59
|
|
8
|
1
|
|
|
1
|
|
688
|
use LWP::Simple qw(get); |
|
1
|
|
|
|
|
165402
|
|
|
1
|
|
|
|
|
10
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
our @EXPORT = qw(get_gold_price get_silver_price); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(get_raw_material_price); |
13
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ] ); |
14
|
1
|
|
|
1
|
|
315
|
use base qw(Exporter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
411
|
|
15
|
|
|
|
|
|
|
my $base_url = 'http://www.finanzen.net/rohstoffe'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub get_raw_material_price { |
18
|
2
|
|
|
2
|
0
|
5
|
my $url = shift; |
19
|
2
|
|
|
|
|
12
|
for ( split /\n/, get($url) ) { |
20
|
46
|
100
|
|
|
|
1411443
|
next unless m# | (\d+?),(\d{2}) (?:USD|EUR) je 1 kg (?:Gold|Silber) | #ms;
21
|
2
|
|
|
|
|
10
|
my $price = "$1$2"; |
22
|
2
|
|
|
|
|
17
|
return $price / 100000; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub get_gold_price { |
28
|
1
|
|
50
|
1
|
0
|
9
|
my $unit = shift || 'euro'; |
29
|
1
|
50
|
33
|
|
|
8
|
unless ( $unit eq 'euro' or $unit eq 'dollar' ) { |
30
|
0
|
|
|
|
|
0
|
croak "Either use 'euro' or 'dollar'"; |
31
|
|
|
|
|
|
|
} |
32
|
1
|
|
|
|
|
5
|
return get_raw_material_price("$base_url/goldpreis/$unit"); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub get_silver_price { |
36
|
1
|
|
50
|
1
|
0
|
16
|
my $unit = shift || 'euro'; |
37
|
1
|
50
|
33
|
|
|
6
|
unless ( $unit eq 'euro' or $unit eq 'dollar' ) { |
38
|
0
|
|
|
|
|
0
|
croak "Either use 'euro' or 'dollar'"; |
39
|
|
|
|
|
|
|
} |
40
|
1
|
|
|
|
|
6
|
return get_raw_material_price("$base_url/silberpreis/$unit"); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |