Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
#!/usr/bin/perl
use warnings;
use strict;
use 5.010;
use File::Spec::Functions qw(catfile);
sub make_inc_hook
{
my %new_vals = @_;
my ($path) = grep { -f $_ } map {
catfile( $_, qw/ AnyEvent constants.pl / );
} @INC or die "Couldn't find AnyEvent/constants.pl";
open my $fh, '<', $path or die "open: $!";
my $const_match = sprintf 'sub (%s) [(][)] { [^ ]+ }',
join q{|}, keys %new_vals;
my $filter = sub {
return 0 unless $_;
s{$const_match}{sub $1 () { $new_vals{$1} }};
return 1;
};
return sub {
my ($self, $target) = @_;
return undef unless ( $target eq 'AnyEvent/constants.pl' );
return ( $fh, $filter );
};
}
unshift @INC, make_inc_hook( WIN32 => 1,
WSAEINVAL => 1002,
WSAEWOULDBLOCK => 10035,
WSAEINPROGRESS => 10036,
);
require "AnyEvent/constants.pl";
say "AnyEvent::WIN32() = ", AnyEvent::WIN32();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.