p 'p @{jl r "history-command"} + 0'
And tada, I have 3997 history entries.
To understand what this does you can just run p
or man p
or man App::p
for documentation:
Usage: p [-lneE etc] 'code'
The code can make use of:
r to File::Slurp::read_file
w to File::Slurp::write_file
S to say()
p to print()
dd to Data::Dump::dd()
jd to JSON::XS::encode (utf8/pretty)
jl to JSON::XS::decode (utf8/allow nonref) a thing
yd to YAML::Dump()
yl to YAML::Load()
Basically the above one-liner does the equivalent of:
perl -MJSON::XS -MFile::Slurp -E \
'print @{decode_json(read_file("history-command"))} + 0'
By the way, the "+ 0" evaluates the array in scalar context which returns the size of the array. So did I find out if this was the cause of my firefox slowdown? No, it was just a misbehaving tab. But at least I had fun playing with App::p.
There is another neat thing about App::p.
Because it happens to provide an executable named 'p', you can install it
simply with sudo cpanm p
.
test -f "$x" || continue
http://www.slideshare.net/obrajesse/oscon-2011-perl-516-and-beyond
]]>use Test::Class::Sugar;
testclass exercises Foo {
test that Foo knows his brother {
my $foo = Foo->new();
is $foo->brother(), 'bar', "yes, foo's brother is bar";
}test that Foo can poo {
my $foo = Foo->new();
ok $foo->poo, "good job, foo can poo";
}
}
Test::Class->runtests;
I have not seen a testing framework in any other language as readable, intuitive and fun to use as that. Just because you have seen or written unreadable perl code, it is not fair to say that "perl is unreadable".