chorny's Journal chorny's use Perl Journal en-us use Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners. 2012-01-25T02:48:39+00:00 pudge Technology hourly 1 1970-01-01T00:00+00:00 chorny's Journal subtypes + type strictness in Perl <tt>file<br><br>package IPType;<br>use Regexp::Common 2.105;<br>use MooseX::Types::Moose qw( Str );<br>use MooseX::Types -declare =&gt; [ qw(IP) ];<br><br>subtype IP, as Str, where {<br>&nbsp; &nbsp; &nbsp; &nbsp;$_ =~<nobr> <wbr></nobr>/\A $RE{net}{IPv4} \z/msx<br>}, message {<br>&nbsp; &nbsp; &nbsp; &nbsp;"'$_' is not a valid IP";<br>};<br><br>file<br><br>use IPType qw/IP/;<br>use MooseX::Lexical::Types qw/IP/;<br><br>my IP $foo;&nbsp; &nbsp;# declare typed variable<br>$foo = '';&nbsp; &nbsp; &nbsp;# works<br>$foo = 'bar';&nbsp; # fails<br></tt> chorny 2010-08-08T20:08:38+00:00 journal eumm-migrate - easy way to migrate to Module::Build <p> Continuing celebration of Perl birthday... </p><p>ExtUtils::MakeMaker is a well known and well problematic module for installing Perl modules. </p><p> eumm-migrate is a tool I wrote to migrate from ExtUtils::MakeMaker to Module::Build. It executes Makefile.PL with fake ExtUtils::MakeMaker and rewrites all parameters for WriteMakefile into corresponding params of Module::Build-&gt;new. Calls to 'prompt' are also intercepted and corresponding 'prompt' is written to Build.PL. All other info should be ported manually. </p><p> Install <a href="">App::EUMM::Migrate</a> from CPAN and just run (it will be in your PATH) in directory with Makefile.PL. If you use Github, Internet connection is recommended. </p><p> eumm-migrate tries to automatically detect some properties like license, minimum Perl version required and repository used. </p><p> If someone needs it, I can also add a Module::Install writer. </p><p> P.S. If you want to just use new features of EU::MM, see <a href="">eumm-upgrade</a>. </p> chorny 2009-12-29T20:35:30+00:00 journal Upgrade you Makefile.PL with eumm-upgrade <p> I decided to celebrate Perl birthday with several new tools. First one is 'eumm-upgrade'. </p><p> It can be used to allow using new features of ExtUtils::MakeMaker without losing compatibility with older versions. BUILD_REQUIRES is the main new feature (I wrote it). It is important for ActivePerl ppm files, for META.yml and for OS packages. </p><p> eumm-upgrade adds compatibility code to Makefile.PL and tries to automatically detect some properties like license, minimum Perl version required and repository used. </p><p> You can install <a href="">App::EUMM::Upgrade</a> from CPAN. Or just download <a href=""> version 0.21 from Github</a> directly and install from CPAN these modules: <i>File::Slurp Text::FindIndent Github::Fork::Parent ExtUtils::MakeMaker</i>. </p><p> To use, run in directory with Makefile.PL. Old file will be copied to Makefile.PL.bak. If you use Github repository, Internet connection is required. </p><p> You need to check resulting Makefile.PL manually as transformation is done with regular expressions. </p> chorny 2009-12-17T23:30:45+00:00 journal New version of perlver Recently I released a new version of <a href="">perlver utility</a>. perlver and corresponding module Perl::MinimumVersion is a tool to determine minimum Perl version to run your program. New version, 1.22, should support almost all features added in Perl 5.5. I skipped features that are too complex to parse and regexes - PPI does not parse them. Also I added some features of Perl 5.6 that previously were not detected. chorny 2009-11-29T00:28:22+00:00 journal I'm in Ohloh's Top 25 Perl commits! I'm on the 9th place in <a href="">Ohloh Top 25 Perl commits</a> (<a href="">see snapshot</a>)! They are counted by 3 latest calendar month, currently from August.<p> To do this I added all repositories were I worked (more than 1 commit) to Ohloh. Github is a very convenient site to have commits with your name on it - I used it much.</p><p> P.S. I used git-backpan-init from Git-CPAN-Patch to retrieve module history (1 commit for every version on CPAN) for CPAN modules that I maintain (or help to do it), so now I can view history using TortoiseGit. </p> chorny 2009-10-13T22:30:10+00:00 journal Sci-Fi story that mentions Perl <p>If you know Russian, you should read this short story: <a href="">&#1054; &#1087;&#1088;&#1086;&#1075;&#1088;&#1072;&#1084;&#1084;&#1080;&#1089;&#1090;&#1072;&#1093;</a>.</p> chorny 2009-09-13T00:38:17+00:00 journal Usability improvement for Module::AutoInstall <p>Many CPAN module users think that feature(s)+auto_install in Module::AutoInstall/Module::Install ask too many questions. Most prominent user of Module::AutoInstall is Plagger - it may ask up to 96+1 questions, but luckily, many will not be asked because modules are already installed or feature is platform-specific.</p><p>In Module::Install 0.80 I removed first question about required modules (it did not do anything), in future 0.92 (see SVN) it will be even better.<br> For all features, if user asked to install this feature's prerequisites, they will be stored. And in following features, this module will be planned for install, not considered missing. So if all modules, except planned, are installed for a feature, question about this feature will not be asked. This means less annoying questions. </p><p>Next feature I plan for M::I is support for BUILD_REQUIRES parameter for EU::MM (when it will be fixed - current version has bugs).</p> chorny 2009-09-06T23:21:53+00:00 journal Perlcritic standalone for Windows <p>Installing Perl::Critic from CPAN may be hard for a beginner, but I consider perlcritic useful for them too.<br>Possible problems are using CPAN shell and failing installations of modules. Of course you can use it directly on <a href=""></a>, but you will not be able to use command line options like verbosity level and there can be privacy concerns. So I decided to create an executable for Windows. It was necessary to patch Module::ScanDeps to pack Perl::Critic correctly. I committed changes to SVN and when new version will be released, you will be able to build it yourself on any OS. Command line to build is<br><tt><br>&gt; pp -M PPI::XS -M Readonly::XS %PATH_TO_YOUR_BIN%/perlcritic<br></tt></p><p>PPI::XS and Readonly::XS are C versions of parts of PPI and Readonly. They are used automatically by corresponding modules when they are available.</p><p>Now beginners can use Perl::Critic without installing it. I'm planning to update this file periodically. I also want to make Perl::Critic more friendly to beginners.</p><p>Please link to <a href=""></a> - page with instructions, not to exe file directly.</p><p>If you want to use <a href="">Perl::Critic on iPhone, it recently became available in Cydia repository</a>.</p> chorny 2009-08-31T12:44:43+00:00 journal RFC: auto install C (and other) deps on OS level <p>I'd like to allow distributions to specify dependencies on OS packages (OS name, for ex, Debian =&gt; OS package, for every OS).<br>For ex., for XML::Parser:<br>{<br>'Fedora' =&gt; 'expat-devel',<br>'Debian=&gt;'expat-devel-debian-name',<br>}.</p><p>Steps to implement this:<br>1. Research if deps names change in different OS versions.<br>2. Finish Linux::Distribution changes.<br>3. There are several CPAN modules to interface package managers: Linux::APT, RPM, RPM2, RPM4. Slackware::Slackget is a package manager. Try several of them and patch/rewrite if necessary.<br>4. Write a general module to interface them, with Linux dist detection by Linux::Distribution. It can be named Package::Installer.<br>5. As experiment, write Module::Install plugin that will ask to install OS package if Package::Installer is installed. Use `sudo` if user is not root.<br>6. Teach CPAN/CPANPLUS to do it. List of deps can be written in JSON file.</p><p>Advantages of this idea:<br>1. Easier installation of modules. And it would be more clear why install failed.<br>2. Better and more useful cpantesters results.</p><p>Future possibilities<br>3. More full implementation of automatic CPAN -&gt; package converters (requires separation between work and build deps).<br>4. Teach CPAN/CPANPLUS to install modules from OS package repository.<br>5. Maybe it can also work on Win32, but it requires additional research.</p><p>P.S. It just came to my mind, that CPAN -&gt; package dependencies can also be stored in some web DB edited by users.</p> chorny 2009-07-31T08:49:29+00:00 cpan Automating Freshmeat submissions <p>Reading about <a href="">low number of Perl project announces on Freshmeat</a>, I also thought about automating this. Freshmeat has <a href="">XML-RPC interface</a> for submitting new releases of existing Freshmeat projects. It requires Freshmeat login/pass, project id, branch name (list of them can be fetched using 'fetch_branch_list' method) - can be filled automatically if only one exists, new version, changes (string, no HTML, character limit 600 chars), release focus (number) and different URLs. Some of this fields are missing in CPAN distibutions, so they need to be stored somewhere.</p><p>CPAN has 2 modules for XML-RPC: XML::RPC and RPC::XML. RPC::XML <a href="">hangs on Windows</a>, so I tried XML::RPC. XML::RPC had no tests, and thus failed installation, so I wrote very simple tests and new version was already released.</p><p>Example that fetches list of licenses from Freshmeat:<br><code><br>use XML::RPC;</code></p><p><code>my $xmlrpc = XML::RPC-&gt;new('');<br>my $result = $xmlrpc-&gt;call( 'fetch_available_licenses', {} );</code></p><p><code>print join("\n",@$result);<br></code></p><p>Another CPAN module is WWW::Freshmeat. It can only fetch project description. It has only load test, so I <a href="">added a real one</a>.</p> chorny 2009-01-02T13:42:33+00:00 journal James A Duncan from Fotango Does anybody know e-mail of James A Duncan (worked in Fotango)? I have a serious patch for <a href=""> Attribute::Signature</a> and would like him to apply it, or I can help in co-maintaining it. chorny 2008-06-10T13:51:24+00:00 cpan Stevey's Tech News Funny: <a href="">Stevey's Tech News, #1</a> chorny 2007-09-05T19:14:12+00:00 journal