понедельник, 2 ноября 2015 г.

Сreate a cpanfile with your dependencies automatically, how?

cpanm App::scan_prereqs_cpanfile
scan-prereqs-cpanfile > cpanfile
cpanm Test::Requires::Scanner
scan-prereqs-cpanfile --scan-test-requires > cpanfile
cpanm --installdeps .
What is cpanfile and why do I want to use it
Why I use cpanfile (and you should too)
Install perl module without test
cpan[1]> notest install FooBarBaz
perl -MCPAN -e "foreach (@ARGV) { CPAN::Shell->rematein('notest', 'install', $_) }" %1
view raw pannti.bat hosted with ❤ by GitHub

среда, 9 сентября 2015 г.

Unknown encoding 'UTF-16BE

I'm decided to create portable https://metacpan.org/pod/release/MISHIN/FamilyTreeInfo-2.3.19/lib/Ftree.pod
and got error:

The application raised the following error: Unknown encoding 'UTF-16BE' at C:/Ftree-portable/lib/DataParsers/ExcelFormat.pm line 100. and the StackTrace middleware couldn't catch its stack trace, possibly because your application overrides $SIG{__DIE__} by itself, preventing the middleware from working correctly. Remove the offending code or module that does it: known examples are CGI::Carp and Carp::Always.

I'm decided error with copy
this module
c:\test_app\strawberry-perl-5.20.0.1-64bit-portable\perl\lib\Encode\Unicode.pm
c:\test_app\strawberry-perl-5.20.0.1-64bit-portable\perl\lib\Encode\Unicode\UTF7.pm
to my distribution

Waw!

среда, 2 сентября 2015 г.

My universal debugger on perl


use FindBin '$RealBin';
use Log::Log4perl qw(:easy);
my $log_file = $RealBin . "/show_image.log";
#Init logging
Log::Log4perl->easy_init(
{ level => $DEBUG,
file => ":utf8>>$log_file",
layout => '%d %p> %m%n'
}
);
my $msg = qq{image name is $picture_directory/$id.jpg};
INFO($msg);
view raw debug.pl hosted with ❤ by GitHub
Simply put output to log file. Voilà.

среда, 1 июля 2015 г.

metacpan grep

If you don't know there are cool stuff grep.cpan.me
You can specify different regex queries
author:(MIYAGAWA|DCONWAY|BDFOY|SZABGAB) shift or die

I get new task from Neil according CPAN PRC July assignment

Hi mishin,

Your distribution for July is Data-MessagePack:
    https://metacpan.org/release/Data-MessagePack

You should be able to find your dist on github at:
    https://github.com/msgpack/msgpack-perl

Notes on your distribution:
 * The distribution has CPAN Testers failures, so you could look at those:
       http://www.cpantesters.org/distro/D/Data-MessagePack.html
 * The distribution has CPANTS warnings - check out its page for details:
       http://cpants.cpanauthors.org/dist/Data-MessagePack

If you really can't work with this dist, get in touch to request
a new assignment. The list of assignments will be published in 5 days.

When you've completed your assignment, please send me email with subject
"I'm done". Include your github username in the body of your email.
You should have done at least one pull request, but you don't have to
wait for it to be merged when you claim "done", that's up to you.

You can discuss ideas for your PR in a number of places:
 a. The mailing list
 b. The #pr-challenge channel on irc.perl.org
Please get in touch with the author of your assigned dist, to see if there's
anything they'd like you to do, and to check any ideas you might have.

If you decide to drop out, please let me know, by sending an email "I quit",
including your github username.

Have fun,
Neil

So CPANTS has trouble


Kwalitee Fails

Core metrics

Excellent. This distribution passes all the core metrics.

Extra metrics

These fails affect your total Kwalitee score, but don't affect the one for the Game. Some of them should be fixed by all means. Others are just matters of taste.
metricremedy
use warnings
This distribution does not 'use warnings;' (or its equivalents) in all of its modules. Note that this is not about that your modules actually warn when something bad happens. It's bad if nobody can tell if a module warns or not, without reading the source code of your favorite module that actually enforces warnings. In other words, it's bad if someone feels the need to add 'use warnings' to your modules.
Add 'use warnings' (or its equivalents) to all modules (this will require perl > 5.6), or convince us that your favorite module is well-known enough and people can easily see the modules warn when something bad happens.

Experimental metrics

These fails are not serious and don't affect your Kwalitee scores at all.
metricremedy
meta yml has provides
This distribution does not have a list of provided modules defined in META.yml.
Add all modules contained in this distribution to the META.yml field 'provides'. Module::Build or Dist::Zilla::Plugin::MetaProvides do this automatically for you.
has separate license file
This distribution does not have a LICENSE or LICENCE file in its root directory.
This is not a critical issue. Currently mainly informative for the CPANTS authors. It might be removed later.


pull request Done!

second, adding separate licence 
so these changes megred in one pull request
third, I dont know, acccording to http://cpants.cpanauthors.org/author/gfuji

Data-Clone2014-05-06131.429                               
               
Data-MessagePack2013-09-01131.429                                              
Data-Util2014-03-05128.571                                              
Data-MessagePack has cpants rating 131.429, maximum is 134.286
I think it's enough

понедельник, 22 июня 2015 г.

list pod files ordering by count lines on perl


use strict;
use warnings;
use 5.010;
use Carp;
use English qw(-no_match_vars);
use FindBin '$RealBin';
use Log::Log4perl qw(:easy);
use open qw/:std :utf8/;
use Path::Iterator::Rule;
use IO::All;
use File::Spec::Functions qw(catdir splitdir);
use IPC::Open3;
exit main();
sub main {
my $log_file = $RealBin . "/$0.log";
#Init logging
Log::Log4perl->easy_init(
{ level => $DEBUG,
file => ":utf8>>$log_file",
layout => '%d %p> - %m%n'
}
);
$ENV{PATH} = $ENV{PATH} . q{;C:/Dwimperl/perl/bin};
my $cmd = q{C:/Dwimperl/perl/bin/perldoc.bat -l perldoc};
my @pod_path = splitdir(run_shell($cmd));
my $pod_path = catdir(@pod_path[0 .. $#pod_path - 1]);
my $rule = Path::Iterator::Rule->new;
$rule->name("*.pod");
my $it = $rule->iter($pod_path);
my %pod_files = ();
while (my $file = $it->()) {
my $io = io $file;
my $cnt = scalar $io->getlines;
$pod_files{$file} = $cnt;
}
foreach
my $name (sort { $pod_files{$a} <=> $pod_files{$b} } keys %pod_files)
{
INFO(sprintf "%-8s %s \n", $name, $pod_files{$name});
printf "%-8s %s \n", $name, $pod_files{$name};
}
return 0;
}
sub run_shell {
my ($cmd) = @_;
my $EMPTY = q{};
my ($HIS_IN, $HIS_OUT, $HIS_ERR) = ($EMPTY, $EMPTY, $EMPTY);
my (@outlines, @errlines,@args) = ((), ());
my $childpid = open3($HIS_IN, $HIS_OUT, $HIS_ERR, $cmd, @args);
$ret = print {$HIS_IN} "stuff\n";
close $HIS_IN or croak "unable to close: $HIS_IN $ERRNO";
; # Give end of file to kid.
if ($HIS_OUT) {
@outlines = <$HIS_OUT>; # Read till EOF.
INFO(" STDOUT:\n" . (join "\n", grep { defined; } @outlines));
}
if ($HIS_ERR) {
@errlines = <$HIS_ERR>; # XXX: block potential if massive
ERROR(" STDERR:\n" . (join "\n", grep { defined; } @errlines));
}
close $HIS_OUT or croak "unable to close: $HIS_OUT $ERRNO";
waitpid $childpid, 0;
if ($CHILD_ERROR) {
ERROR("That child exited with wait status of $CHILD_ERROR\n");
}
return @outlines;
}
view raw find_pod.pl hosted with ❤ by GitHub

вторник, 2 июня 2015 г.

script which I made #cpanpr for June


Hi, Neil, I'v done it
use strict;
use warnings;
use 5.010;
use Path::Iterator::Rule;
use File::Slurp;
die "Usage: $0 DIRs" if not @ARGV;
my $rule = Path::Iterator::Rule->new;
$rule->name("*.pm");
my $it = $rule->iter(@ARGV);
while ( my $file = $it->() ) {
say "use strict added to $file";
add_strict_to_file($file);
}
sub add_strict_to_file {
#http://perlmaven.com/splice-to-slice-and-dice-arrays-in-perl
my ($file) = @_;
my @lines = read_file($file);
my @strict = ( 'use strict;', 'use warnings;', '' );
splice @lines, 1, 0, ( join "\n", @strict );
write_file( $file, \@lines );
}
view raw iterate.pl hosted with ❤ by GitHub

concat multiple file with perl iterator


thanks for Gabor
use strict;
use warnings;
use 5.010;
use Path::Iterator::Rule;
use File::Slurp;
die "Usage: $0 DIRs" if not @ARGV;
my $rule = Path::Iterator::Rule->new;
$rule->name("*.sql");
my $big_sql = $ARGV[0] . '/big.sql';
my $it = $rule->iter(@ARGV);
while (my $file = $it->()) {
say "$file was added to $big_sql";
write_file($big_sql, {append => 1}, read_file($file));
}
#thanks for Gabor

понедельник, 1 июня 2015 г.

june pull request

I'v got new task from Neil

01.06.2015, 12:01, "Neil Bowers" <neil@bowers.com>:
> Hi mishin,
>
> Your distribution for June is Memcached-libmemcached:
>     https://metacpan.org/release/Memcached-libmemcached
>
> You should be able to find your dist on github at:
>     https://github.com/timbunce/Memcached-libmemcached
>
> Notes on your distribution:
>  * The distribution has CPANTS warnings - check out its page for details:
>        http://cpants.cpanauthors.org/dist/Memcached-libmemcached
>
> If you really can't work with this dist, get in touch to request
> a new assignment. The list of assignments will be published in 5 days.
>
> When you've completed your assignment, please send me email with subject
> "I'm done". Include your github username in the body of your email.
> You should have done at least one pull request, but you don't have to
> wait for it to be merged when you claim "done", that's up to you.
>
> You can discuss ideas for your PR in a number of places:
>  a. The mailing list
>  b. The #pr-challenge channel on irc.perl.org
> Please get in touch with the author of your assigned dist, to see if there's
> anything they'd like you to do, and to check any ideas you might have.
>
> If you decide to drop out, please let me know, by sending an email "I quit",
> including your github username.
>
> Have fun,
> Neil



воскресенье, 26 апреля 2015 г.

how add gist code to blogger

It's very simple

1. Make gist

https://gist.github.com/


2. https://gist.github.com/mishin/a955752a26e3c6baa3b6
Copy Embed html


3. So, we got <script src="https://gist.github.com/mishin/a955752a26e3c6baa3b6.js"></script>
4. And put this code to end of html
5.




Thats is!!
#This is my perl tips collection:
http://grep.cpan.me/?q=author%3A%28MIYAGAWA%7CDCONWAY%7CBDFOY%7CSZABGAB%29+shift
author:(MIYAGAWA|DCONWAY|BDFOY|SZABGAB) shift
http://eax.me/perl5-oop/
http://grep.cpan.me/?q=author%3A%28MIYAGAWA%7CDCONWAY%7CBDFOY%29+__DATA__
author:(MIYAGAWA|DCONWAY|BDFOY) __DATA__
→ milla-tutorial$ sp_ch () {(cat $1|aspell --lang=ru-yo list|aspell --lang=en list); };sp_ch lib/POD2/RU/perlretut.pod
{ (cat $1|aspell --lang=ru-yo list|aspell --lang=en list); }
sp_ch () {(cat $1|aspell --lang=ru-yo list|aspell --lang=en list); };sp_ch lib/POD2/RU/perlretut.pod
perl -M"File::Slurp qw(edit_file)" -e "edit_file { s/=item (\d+)/=item C<$1>/g } 'lib/POD2/RU/perlretut.pod' "
perl -pi.bak -e 's/=item (\d+)/=item C<$1>/g' lib/POD2/RU/perlretut.pod
view raw perl_gist.pl hosted with ❤ by GitHub

how hack git

Hi, my script to full github history and make longest stick:
https://github.com/mishin/presentation/blob/master/01_test_git.pl






use Modern::Perl;
use Git::Repository;
use File::Slurp qw( :edit );
my $url = 'https://github.com/mishin/perldoc-ru.git';
my $dir = '/home/mishin/github/test_repo';
#Git::Repository->run( clone => $url => $dir );
my $r = Git::Repository->new( work_tree => $dir );
use DateTime;
use DateTime::Format::Strptime;
my $dt = DateTime->new(
year => 2015,
month => 02,
day => 07,
hour => 16,
minute => 12,
second => 47,
nanosecond => 500000000,
time_zone => 'Europe/Moscow',
);
#'Fri Jul 26 19:34:15 2013 +0200';
my $formatter =
DateTime::Format::Strptime->new( pattern => '%a %b %d %H:%M %Y %z' );
$dt->set_formatter($formatter);
my $n = 1;
for ( 1 .. 50 ) {
#inplace edit
edit_file { s/__NUMBER\d+__/__NUMBER${n}__/ }
$dir . '/pod2-ru/POD2-RU/scripts/get_pod_one_liners.md';
say "iteration №${n}";
say 'edit ok';
$r->run( add => '.' );
say 'add ok';
my $date = $dt->_stringify();
$r->run( commit => '-m', "my $n commit message", "--date=$date" );
say 'commit ok';
$dt->add( days => 1 );
$n++;
}
view raw 01_hack_git.pl hosted with ❤ by GitHub

суббота, 25 апреля 2015 г.

letter to perl-thanks@perl.org

According to Gabor post http://perlmaven.com/improve-your-communication-skills
I decided to write something on english every day.

Some times ago I write to perl-thanks@perl.org

Thanks a lot for all beautifull things, that you got
Hi, Larry!! Good luck!
I never mind what i could do without perl.
Use Perl or die!! Perl is my paycheck!!

best regards,
Nikolay Mishin

So I've got answer from Ricardo Signes