Fast Perl Dependency Isolation

Fast Perl Dependency Isolation

I gave a presentation at OpenWest about Perl dependency isolation using perlbrew and plenv + carton: …

Perl Hash Reference Partial Copy

Given a multi-level deep hash reference: my $conf = { bucket => { list => { h => 'help me', _sub => sub { say "something" } } }, file => { upload => { h => 'help me too', _sub => sub { say "else" } } } }; We want to remove all of the _sub keys and put them in a separate …

Perl Dependency Isolation

Perl Dependency Isolation

I gave a talk about Perl dependency isolation at Salt Lake Perl Mongers. …

Devel::Cover Notes

Some notes for using Devel::Cover. Gathering coverage CPAN::Reporter doesn't have a build step, so we prove -l; we also don't want to cover the world, so we set -inc=lib: HARNESS_PERL_SWITCHES=-MDevel::Cover=-inc=lib prove -l or: PERL5OPT=-MDevel::Cover prove t/some-test.t This …

Functional Programming with Perl

Functional Programming with Perl

I gave a talk about functional programming with Perl at Salt Lake Perl Mongers. …

Asynchronous Programming Patterns in Perl

Asynchronous Programming Patterns in Perl

I gave a talk about asynchronous programming patterns in Perl at Salt Lake Perl Mongers. This presentation ultimately landed me a new job—thank you to SLC.pm! …

Perl Log Processing Goodies

Here are some Perl goodies I forget to write down once I've remembered them long enough to solve my problem. Line range If you want to print all the lines in a file after a certain line number: perl -ne 'print if (2655641 .. -1)' some.log This will print …

DBD::mysql Integer Type Coercion

DBD::mysql knows that certain MySQL column types are integers with this call: $sth->execute; $nums = $sth->{'mysql_is_num'} || []; You can iterate over $nums and see which columns are numeric-type columns. However, when you pull the data out, it's converted to a string. So, what used to …

Perl List of Anonymous Hashes

Here's a nice trick from perlfunc's map entry: To force an anon hash constructor use "+{": @hashes = map +{ lc($_) => 1 }, @array # EXPR, so needs # comma at end to get a list of anonymous hashes each with only one entry apiece. …

Renaming Hash Keys

Say you have a hash: my %hash = (foo => 'fooey', bar => 'barey', baz => 'bazey', blech => 'blechey'); and you want to rename some of the hash keys, create another hash that holds the new names of the keys: ## old-name => new-name my %new = (foo => 'foooo', bar => …

Profiling with Devel::NYTProf

To selectively profile during only a portion of the code, invoke like this: $ NYTPROF=start=no perl -d:NYTProf t/load.t -v Then inside t/load.t add the following directives which tell Devel::NYTProf to start and stop profiling: DB::enable_profile(); ... ## profile this section DB::finish_profile( …