code_junkie

How do YOU manage Perl modules when using a package manager?

Nov 13th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. $ perl5.10.0 program.pl
  2.  
  3. #!perl
  4.  
  5. use 5.010;
  6.  
  7. use strict;
  8. use warnings;
  9.  
  10. use File::Basename;
  11. use File::Spec::Functions;
  12.  
  13. my $perls_directory = catfile(
  14. $ARGV[0] // '/usr/local/perls',
  15. 'perl*'
  16. );
  17. die "$perls_directory does not exist!n"
  18. unless -d dirname $perls_directory;
  19.  
  20. my $links_directory = $ARGV[1] // catfile( $ENV{HOME}, 'bin' ); #/
  21. die "$links_directory does not exist!n" unless -d $links_directory;
  22.  
  23. foreach my $directory ( glob( $perls_directory ) )
  24. {
  25. say "Processing $directory...";
  26.  
  27. unless( -e catfile( $directory, 'bin' ) )
  28. {
  29. say "tNo bin/ directory. Skipping!";
  30. next;
  31. }
  32.  
  33. my @perls = glob( catfile( $directory, qw( bin perl5* ) ) );
  34.  
  35. my( $perl_version ) = $perls[0] =~ m/(5.d+.d+)z/;
  36. say "tperl version is $perl_version";
  37.  
  38. foreach my $bin ( glob( catfile( $directory, 'bin', '*' ) ) )
  39. {
  40. say "tFound $bin";
  41. my $basename = basename( $bin );
  42.  
  43. my $link_basename = do {
  44. if( $basename =~ m/5.d+.d+z/) { $basename }
  45. else { "$basename$perl_version" }
  46. };
  47.  
  48. my $link = catfile( $links_directory, $link_basename );
  49. next if -e $link;
  50. say "ttlinking $bin => $link";
  51. symlink $bin => $link or
  52. warn "ttCould not create symlink [$!]: $bin => $link!";
  53. }
  54. }
  55.  
  56. $ module-starter --mi --module=Module::Name --author="Me" [email protected]
Add Comment
Please, Sign In to add comment