Last active
March 22, 2016 03:56
-
-
Save typhonius/8d75a563a2f8bdef648f to your computer and use it in GitHub Desktop.
Super delicious perl script to get a list of modules from d.o and select one at random for the user to port to Drupal 8. Also it's perlcritic brutal approved!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use LWP::Simple; | |
use Scalar::Util qw(looks_like_number); | |
our $VERSION = 1.337; | |
sub gimmeamodule { | |
my $moduledata = get( | |
'http://drupalcode.org/sandbox/greggles/1481160.git/blob_plain/refs/heads/master:/allmodules.txt' | |
); | |
if ($moduledata) { | |
my @modules = split /\n/sxm, $moduledata; | |
my $linecount = scalar @modules; | |
if ( !$linecount ) { | |
return; | |
} | |
my $count; | |
if ( !$ARGV[0] || !looks_like_number($ARGV[0]) ) { | |
$count = 1; | |
} else { | |
$count = $ARGV[0] | |
} | |
my $rand; | |
my @array; | |
for (0..$count) { | |
$rand = int rand $linecount; | |
push @array, "You should port $modules[$rand]!\nFind out more here https://drupal.org/project/$modules[$rand]\n"; | |
} | |
return @array; | |
} | |
return; | |
} | |
my @return = gimmeamodule(); | |
if (@return) { | |
exit 1 if !print @return; | |
} | |
else { | |
die "Unable to get/parse module data\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment