Converting Module::Install prereqs to Dist::Zilla with elisp

After half a day of yak-shaving that started with having to port yet another Makefile.PL to the dist.ini format, I am now finally able to post this small snippet of elisp code to blogs.perl.org from within emacs (more on that later):
(defun sbw/prereqs-to-dist-zilla ()
  (interactive)
  (save-excursion
   (while
       (re-search-forward
        (concat
         "^\\(build_\\)?requires *['\"]\\([^'\"]*\\)['\"]"
         " *\\(=>\\|,\\)? *['\"]?\\([0-9_.]*\\)?['\"]? *[;,]")
        nil t)
     (replace-match
      (let
          ((module (match-substitute-replacement "\\2"))
           (version (match-substitute-replacement "\\4")))
        (concat module " = " (if (string= version "") "0" version)))
      t nil)
     ))
)
Hope someone finds this useful... oh, and, yeah: first post!
Cheers, Sebastian

2 Comments

Have you looked at Dist::Zooky on CPAN? I find it does a pretty good first pass.

Leave a comment

About Sebastian Willert

user-pic Programming Perl 5 in Emacs for over a decade, blogging since a few minutes. Expect tidbits about both technologies here (if at all, I'm not too sure I can develop a blogging habit).