February 2010 Archives

Module::Name->method

| No Comments | No TrackBacks
package Module::Name;

use Moose;
use Scalar::Util 'blessed';

has 'verbose' => ( is => 'rw', isa => 'Int', default => 1 );

sub method {
    my $self = shift;
    $self = $self->new()
        if not blessed $self;

    print "hell world\n"
        if $self->verbose;

    return;
}

1;

This allows "method" to be called in two ways:

Module::Name->method;
Module::Name->new(verbose => 0)->method;
@@ -1,25 +1,25 @@
-diff -Naur a/DhMakePerl.pm b/DhMakePerl.pm
---- a/DhMakePerl.pm	2010-02-15 17:28:42.000000000 +0100
-+++ b/DhMakePerl.pm	2010-02-15 17:17:55.000000000 +0100
+diff -Naur DhMakePerl.orig/DhMakePerl.pm DhMakePerl/DhMakePerl.pm
+--- DhMakePerl.orig/DhMakePerl.pm	2010-02-19 13:36:58.000000000 +0100
++++ DhMakePerl/DhMakePerl.pm	2010-02-22 18:40:12.000000000 +0100
 @@ -65,6 +65,8 @@
  use WWW::Mechanize ();
  use YAML           ();
  use version qw( qv );
 +use Debian::Apt::PM;
 +our $aptpm = Debian::Apt::PM->new();
  
  # TODO:
  # * get more info from the package (maybe using CPAN methods)
-@@ -1132,8 +1134,12 @@
+@@ -1131,9 +1133,11 @@
+             $dep = Debian::Dependency->new( 'perl',
                  $self->nice_perl_ver( $dep_hash->{$module} ) );
          }
-         elsif ($apt_contents) {
+-        elsif ($apt_contents) {
 -            $dep = $apt_contents->find_perl_module_package( $module,
 -                $dep_hash->{$module} );
-+            #$dep = $apt_contents->find_perl_module_package( $module,
-+            #    $dep_hash->{$module} );
++        else {
 +            my $info = $aptpm->find($module, $dep_hash->{$module});
 +            if ($info and $info->{'min'}) {
 +                $dep = Debian::Dependency->new( $info->{'min'}->{'package'}, $info->{'min'}->{'version'} );
 +            }
          }

This is really hard to read and understand...

perl -MDebian::Apt::PM -MList::MoreUtils=uniq -MYAML -MApp::Cache -MCPAN -le '$a=shift @ARGV or die; $p=Debian::Apt::PM->new(); $c=App::Cache->new(); do { local *STDOUT; $r = join "\n", grep { not $p->find($_) } grep { CPAN::Shell->expand("Module", $_) } uniq map { s/-/::/g; $_ } map { $_->{"name"} } map { eval { Load($_) } || {} } map { $c->get_url("http://archive.cpan.cz/authors/id/".substr($a,0,1)."/".substr($a,0,2)."/$a/$_") } map { map { $_ =~ /\.meta$/ ? $_ : () } @{$_} } CPAN::Shell->expand("Author", $a)->ls;}; print $r;' GAAS

A little more readable version:

use Debian::Apt::PM;
use List::MoreUtils 'uniq';
use YAML;
use App::Cache;
use CPAN;

$a=shift @ARGV or die;
$p=Debian::Apt::PM->new();
$c=App::Cache->new();

do {
	local *STDOUT;
	$r =
		join "\n",
		grep { not $p->find($_) }
		grep { CPAN::Shell->expand("Module", $_) }
		uniq
		map { s/-/::/g; $_ }
		map { $_->{"name"} }
		map { eval { Load($_) } || {} }
		map { $c->get_url("http://archive.cpan.cz/authors/id/".substr($a,0,1)."/".substr($a,0,2)."/$a/$_") }
		map { map { $_ =~ /\.meta$/ ? $_ : ()  } @{$_} }
		CPAN::Shell->expand("Author", $a)->ls
	;
};

print $r;

It prints out CPAN modules from author id that are not packaged in Debian. Will work for 99% of cases. Only problem are the distributions that have "custom" names, like libwww-perl, as the package name is created from the distribution name that is read from .meta files.

The Firefox Addon was just approved - 59864

Pages

About this Archive

This page is an archive of entries from February 2010 listed from newest to oldest.

January 2010 is the previous archive.

March 2010 is the next archive.

Find recent content on the main index or look in the archives to find all content.