This file is indexed.

/usr/share/perl5/WebService/CIA.pm is in libwebservice-cia-perl 1.4-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
package WebService::CIA;

require 5.005_62;
use strict;
use warnings;
use Carp;

our $VERSION = '1.4';

$WebService::CIA::base_url = "https://www.cia.gov/library/publications/the-world-factbook/";

sub new {

    my $proto = shift;
    my $opts = shift;
    my $class = ref($proto) || $proto;
    my $self = {};

    unless (exists $opts->{Source}) {
        croak("WebService::CIA: No source object specified");
    }
    $self->{SOURCE} = $opts->{Source};

    bless ($self, $class);
    return $self;

}

sub get {

    my $self = shift;
    my ($cc, $f) = @_;
    my $value = $self->source->value($cc, $f);
    return $value;

}

sub get_all_hashref {

    my $self = shift;
    my $country = shift;
    my $data = {};
    foreach my $cc (@$country) {
        $data->{$cc} = $self->source->all($cc);
    }
    return $data;

}

sub get_hashref {

    my $self = shift;
    my ($country, $field) = @_;
    my $data = {};
    foreach my $cc (@$country) {
         $data->{$cc} = {};
         foreach my $f (@$field) {
             $data->{$cc}->{$f} = $self->source->value($cc, $f);
         }
    }
    return $data;

}

sub source {

    my $self = shift;
    return $self->{SOURCE};

}

1;

__END__

=head1 NAME

WebService::CIA - Get information from the CIA World Factbook.


=head1 SYNOPSIS

  use WebService::CIA;
  use WebService::CIA::Source::DBM;
  use WebService::CIA::Source::Web;

  # Get data from a pre-compiled DBM file

  my $source = WebService::CIA::Source::DBM->new({ DBM => "factbook.dbm" });
  my $cia = WebService::CIA->new({ Source => $source });
  $fact = $cia->get("uk", "Population");
  print $fact;

  # Get data direct from the CIA World Factbook

  my $source = WebService::CIA::Source::Web->new();
  my $cia = WebService::CIA->new({ Source => $source });
  $fact = $cia->get("uk", "Population");
  print $fact;


=head1 DESCRIPTION

A module which gets information from the CIA World Factbook.


=head1 Crypt::SSLeay

The most recent version of the CIA World Factbook uses HTTPS to access its
web pages. As such, WebService::CIA requires Crypt::SSLeay which suffers from
the usual cryptographic export restriction mumbo jumbo. Sorry about that.

Users of ActiveState's ActivePerl should see L<http://aspn.activestate.com/ASPN/Downloads/ActivePerl/PPM/Repository>
for instructions on downloading a PPM of Crypt::SSLeay.


=head1 METHODS

=over 4

=item C<new(\%opts)>

Creates a new WebService::CIA object. Takes a hashref, which must contain a "Source"
key whose value is a WebService::CIA::Storage object.


=item C<get($country_code, $field)>

This method retrieves information from the store.

It takes two arguments: a country code (as defined in FIPS 10-4 on
L<https://www.cia.gov/library/publications/the-world-factbook/appendix/appendix-d.html>,
e.g. "uk", "us") and a field name (as defined in
L<https://www.cia.gov/library/publications/the-world-factbook/docs/notesanddefs.html>,
e.g. "Population", "Agriculture - products"). (WebService::CIA::Parser also
creates four extra fields: "URL", "URL - Print", "URL - Flag", and "URL -
Map" which are the URLs of the country's Factbook page, the printable
version of that page, a GIF map of the country, and a GIF flag of the
country respectively.)

The field name is very case and punctuation sensitive.

It returns the value of the field, or C<undef> if the field or country isn't
in the store.

Note that when using WebService::CIA::Store::Web, C<get> will also return C<undef> if
there is an error getting the page.


=item C<get_hashref(\@countries, \@fields)>

This method takes two arguments: an arrayref of country codes and an arrayref
of field names.

It returns a hashref of the form

  {
   'country1' => {
                  'field1' => 'value',
                  'field2' => 'value'
                 },
   'country2' => {
                  'field1' => 'value',
                  'field2' => 'value'
                 }
  }

=item C<get_all_hashref(\@countries)>

Get all the fields available for countries.

It takes one argument, an arrayref of country codes.

It returns a hashref similar to the one from C<get_hashref> above,
containing all the fields available for each country.

=item C<source()>

Get a reference to the WebService::CIA::Source object in use.

=back


=head1 CONFIGURATION VARIABLES

=over 4

=item C<$WebService::CIA::base_url>

Sets the base URL for the Factbook (currently 
"https://www.cia.gov/library/publications/the-world-factbook/"). If the
Factbook changes location, this can be changed to point to the new location
(assuming the relative structure of the Factbook is unchanged).

=back


=head1 AUTHOR

Ian Malpass (ian-cpan@indecorous.com)


=head1 COPYRIGHT

Copyright 2003-2007, Ian Malpass

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

The CIA World Factbook's copyright information page
(L<https://www.cia.gov/library/publications/the-world-factbook/docs/contributor_copyright.html>)
states:

  The Factbook is in the public domain. Accordingly, it may be copied
  freely without permission of the Central Intelligence Agency (CIA).


=head1 SEE ALSO

WebService::CIA::Parser, WebService::CIA::Source::DBM, WebService::CIA::Source::Web


=cut