Net-Curl
view release on metacpan or search on metacpan
lib/Net/Curl/Compat.pm view on Meta::CPAN
use strict;
use warnings;
+# support both Net::Curl (default) and WWW::Curl
+BEGIN { eval { require Net::Curl::Compat; } }
use WWW::Curl::Easy 4.15;
use WWW::Curl::Multi;
=head1 DESCRIPTION
Net::Curl::Compat lets you use Net::Curl in applications and modules
that normally use WWW::Curl. There are several ways to accomplish it:
=head2 EXECUTION
Execute an application through perl with C<-MNet::Curl::Compat> argument:
perl -MNet::Curl::Compat APPLICATION [ARGUMENTS]
=head2 CODE, use Net::Curl by default
Add this line before including any WWW::Curl modules:
BEGIN { eval { require Net::Curl::Compat; } }
This will try to preload Net::Curl, but won't fail if it isn't available.
=head2 CODE, use WWW::Curl by default
Add those lines before all the others that use WWW::Curl:
BEGIN {
eval { require WWW::Curl; }
require Net::Curl::Compat if $@;
}
This will try WWW::Curl first, but will fallback to Net::Curl if that fails.
=head1 NOTE
If you want to write compatible code, DO NOT USE Net::Curl::Compat during
development. This module hides all the incompatibilities, but does not disable
any of the features that are unique to Net::Curl. You could end up using
methods that do not yet form part of official WWW::Curl distribution.
=cut
use strict;
use warnings;
use Carp qw(croak);
our $VERSION = 4.15;
=for Pod::Coverage
VERSION
=cut
# Dirty hack so Test::ConsistentVersion passes
sub VERSION {
return (caller)[0] eq 'Test::ConsistentVersion'
? '0.58'
: $VERSION;
}
my %packages = (
'WWW/Curl.pm' => 0,
'WWW/Curl/Easy.pm' => 420,
'WWW/Curl/Form.pm' => 4289,
'WWW/Curl/Multi.pm' => 5193,
'WWW/Curl/Share.pm' => 6272,
);
my $start = tell *DATA;
unshift @INC, sub {
my $pkg = $packages{ $_[1] };
return unless defined $pkg;
## no critic (RequireUseOfExceptions)
open(my $fh, '<&', *DATA) or croak "can't read from __DATA__";
seek $fh, $start + $pkg, 0;
return $fh;
};
1;
=head1 COPYRIGHT
Copyright (c) 2011-2015 Przemyslaw Iskra <sparky at pld-linux.org>.
You may opt to use, copy, modify, merge, publish, distribute and/or sell
copies of the Software, and permit persons to whom the Software is furnished
to do so, under the terms of the MPL or the MIT/X-derivate licenses. You may
pick one of these licenses.
=cut
__DATA__
package WWW::Curl;
use strict;
use warnings;
use Net::Curl ();
our $VERSION = 4.15;
# copies constants to current namespace
sub _copy_constants
{
my $EXPORT = shift;
my $dest = (shift) . "::";
my $source = shift;
no strict 'refs';
my @constants = grep /^CURL/, keys %{ "$source" };
push @$EXPORT, @constants;
foreach my $name ( @constants ) {
*{ $dest . $name } = \*{ $source . $name };
}
}
( run in 1.253 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )