1# vim:ts=4:sw=4:tw=78 2# $Id: Build.PL 149 2006-02-08 14:52:12Z nicolaw $ 3 4use strict; 5use Module::Build; 6use vars qw($build); 7 8$build = Module::Build->new( 9 module_name => 'WWW::Dilbert', 10 license => 'open_source', 11 create_makefile_pl => 'passthrough', 12 create_readme => 1, 13 create_packlist => 1, 14 sign => 0, 15 16 requires => { 17 'LWP::UserAgent' => 0, 18 'HTTP::Request' => 0, 19 'Carp' => 0, 20 }, 21 22 build_requires => { 23 'Test' => 0, 24 'Test::More' => 0, 25 'Test::Pod' => 0, 26 'Test::Pod::Coverage' => 0, 27 }, 28 ); 29 30$build->create_build_script; 31 32 33# Send perl and module version information home if we've been given 34# permission to do so by a human being - default to not send for automated 35# testing environments, of if the user does not respond within 20 seconds. 36 37my $url = $ENV{AUTOMATED_TESTING} ? undef : may_send_version_information(); 38if ($url) { 39 my @resp = (); 40 eval { 41 local $SIG{ALRM} = sub { die; }; 42 alarm 10; 43 my $ua = LWP::UserAgent->new( 44 agent => 'Build.PL $Revision: 202 $', 45 timeout => 9, 46 max_size => 500, 47 ); 48 $ua->env_proxy; 49 my $response = $ua->get($url); 50 if ($response->is_success()) { 51 for (split(/\s*\n+\s*/, $response->content())) { 52 push @resp, $_ if $_; 53 } 54 } 55 alarm 0; 56 }; 57 print substr($resp[0],0,79) || "Thank you for sending this information."; 58 print "\n\n"; 59} 60 61sub may_send_version_information { 62 eval { 63 require Config; 64 require LWP::UserAgent; 65 }; 66 return undef if $@; 67 68 my $str = sprintf('%s?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s', 69 'http://perlgirl.org.uk/lib/usage.cgi', 70 'name', $build->dist_name(), 71 'version', $build->dist_version(), 72 'osname', $Config::Config{osname}, 73 'archname', $Config::Config{archname}, 74 'osver', $^O, 75 'perlver', $] 76 ); 77 78 print "\nThank you for downloading ".$build->dist_name()."\n\n"; 79 print "I would like to find out how many people are using this software,\n"; 80 print "and on what operating systems and Perl versions. If you have an\n"; 81 print "internet connection, may I transmit the following information:\n\n"; 82 print "$str\n\n"; 83 84 my $send = 0; 85 eval { 86 local $SIG{ALRM} = sub { die; }; 87 alarm 20; 88 $send = $build->y_n('Send this anonymous information?','n'); 89 alarm 0; 90 }; 91 92 return $send ? $str : undef; 93} 94 951; 96 97