h8rt3rmin8r

installdep.pl

Oct 18th, 2020
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2. # [installdep.pl]
  3. #
  4. # ABOUT:
  5. #    Install all perl modules required by a perl script
  6. #
  7. # USAGE:
  8. #    ./installdep.pl <INPUT>
  9. #    where "INPUT" is the path to a valid perl script
  10. #
  11. # REFERENCE:
  12. #    https://stackoverflow.com/a/45469759
  13. #
  14.  
  15. `sudo apt install cpanminus`;
  16. while (<>) {
  17.     if (/USE /i)
  18.     {
  19.         my $line=$_;
  20.         $line=~ s/\s//g;
  21.         $line=~ /^(.*)\./;
  22.         $line=~ s/\;//;
  23.         $line=~s/^USE//i;
  24.         $line=~s/lib.*//i;
  25.         $line=~s/feature.*//i;
  26.         $line=~s/strict//i;
  27.         $line=~s/warnings//i;
  28.         $line =~ s/^(.*)\(.*/$1/;
  29.         unless ($line eq '') {
  30.         my $cmd='sudo cpanm '.$line;
  31.         print "Installing $line \n";
  32.         open my $cmd_fh, "$cmd |";
  33.         while (<$cmd_fh>) {
  34.           print "$_";
  35.         }
  36.         close $cmd_fh;
  37.         print "\n";
  38.     }
  39.     }
  40. }
  41.  
RAW Paste Data