[Wellington-pm] Meeting this evening
Grant McLean
grant at mclean.net.nz
Tue Mar 13 13:43:21 PDT 2012
On Wed, 2012-03-14 at 09:28 +1300, Andrew Chilton wrote:
> Hi everyone,
>
> On 13 March 2012 12:12, Grant McLean <grant at mclean.net.nz> wrote:
> > Meeting tonight - http://wellington.pm.org/
>
> Those talks sounded good.
If Matthew/Lenz would like to send me a PDF/link I'll put them up on the
site.
> I am curious as to what Grants talk was
> though, on the site it says "A quick p"???
I didn't have slides for that, I was just bringing the command-line tool
'p' to people's attention. It's available on CPAN as App::p and is
basically a wrapper for doing Perl 1-liners with less typing.
p 'S "Hello world"'
Is equivalent to:
perl -E 'say "Hello World"'
Which for old school coders is equivalent to:
perl -e 'print "Hello World\n"'
In addition to the 'S' function for 'say', p give you dd (data dump), jd
(JSON dump), yd (YAML::Dump) and others.
It also imports all the functions from List::AllUtils so you can just
say sum(@values) without having to import modules.
Another handy feature is 'autouse', which allows you to call a function
or a method in a package/class and p will automatically 'use' the module
for you.
My example was determining who asks the most questions on Catalyst's
#perl IRC channel by:
* looking for lines which contain a question mark
* extracting the irc nick (first field after the initial timestamp)
* counting lines by nick
* graphing the result using Google chart images
p -nE 'm{^\S+\s(\S+?):.*[?]} && $tally{$1}++ }{ S
ChartImage->pie_url(data => \%tally)' perl.log
Results here: http://bit.ly/z8s6tS
Cheers
Grant
More information about the Wellington-pm
mailing list