If you're like me, you develop your CPAN modules using 'make test'. And, if you're still like me, you use some vi-derived editor. And every once in a while, you'll run into the following:
%prompt> make test make: Fatal error: Don't know how to make target `lib/My/.Module.pm.sw +p'

Ladies and Gentlemen, I have a solution, albeit somewhat ugly, that fixes this. :-)

use strict; use ExtUtils::MakeMaker; { no strict 'refs'; my $libscan = \&{"ExtUtils::MM_Any::libscan"}; *{"ExtUtils::MM_Any::libscan"} = sub { return '' unless $libscan->(@_); return '' if $_[1] =~ /\.swp$/; return $_[1]; }; } WriteMakefile( NAME => 'My::Module', VERSION_FROM => 'lib/My/Module.pm', PREREQ_PM => { 'Test::More' => 0.47, } );

Replies are listed 'Best First'.
Re: Making ExtUtils::MakeMaker ignore .swp files
by PodMaster (Abbot) on Feb 09, 2005 at 12:29 UTC
    Slightly less ugly is to make disttest as a developer, and add \.swp$ to MANIFEST.SKIP (.swp's will be also ignored when you make dist), but that may or may not be desireable.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Huh. I didn't know about disttest. Thanks for the tip.

      However, one difference is that this will create a Foo-Bar-#.## directory, copy everything over, create a META.yml, and other such activities. That can be somewhat expensive.

      Another difference is that this will only run the distribution tests - it won't run any developer tests that are under source control, but not in the MANIFEST.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Making ExtUtils::MakeMaker ignore .swp files
by Anonymous Monk on Jul 21, 2012 at 00:44 UTC

    The "proper" way is to use ExtUtils::MY

    sub MY::libscan { my( $mm, $file ) = @_; return if $file =~ /\.swp$/; # SKIP return $file; } WriteMakefile( ...