AnyData
view release on metacpan or search on metacpan
lib/AnyData.pm view on Meta::CPAN
=head2 Using Remote Files
If the first file parameter of adTie() or adConvert() begins with "http://" or "ftp://", the file is treated as a remote URL and the LWP module is called behind the scenes to fetch the file. If the files are in an area that requires authentication, ...
For example:
# read a remote file and access it via a tied hash
#
my $table = adTie( 'XML', 'http://www.foo.edu/bar.xml' );
# same with username/password
#
my $table = ( 'XML', 'ftp://www.foo.edu/pub/bar.xml', 'r'
{ user => 'me', pass => 'x7dy4'
);
# read a remote file, convert it to an HTML table, and print it
#
print adConvert( 'XML', 'ftp://www.foo.edu/pub/bar.xml', 'HTMLtable' );
=head2 Using Strings and Arrays
lib/AnyData/Storage/RAM.pm view on Meta::CPAN
sub close { my $s = shift; undef $s }
sub get_remote_data {
my $self = shift;
my $file = shift;
my $parser = shift;
$ENV = {} unless defined $ENV;
$^W = 0;
undef $@;
my $user = $self->{user} || $self->{username};
my $pass = $self->{pass} || $self->{password};
eval{ require 'LWP/UserAgent.pm'; };
# eval{ require 'File/DosGlob.pm'; };
die "LWP module not found! $@" if $@;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => $file);
$req->authorization_basic($user, $pass) if $user and $pass;
my $res = $ua->request($req);
die "[$file] : " . $res->message if !$res->is_success;
$^W = 1;
return $res->content;
( run in 0.455 second using v1.01-cache-2.11-cpan-49f99fa48dc )