Perl tricks

From Hexten

Jump to: navigation, search

[edit] Slices of hash, array refs

From http://www.perlmonks.org/?node_id=80399 via http://xoa.petdance.com/How_to:_Take_a_slice_of_a_hashref_or_arrayref

@slice = @{$array_ref}[ @idx ];
@slice = @{$hash_ref}{ @keys };

Because it always takes me way longer (and sometimes a trip to Google) to get it right.

[edit] Stopping in the debugger at a specific test number

use Test::Builder;
if (Test::Builder->new->current_test >= 85) {
    $DB::single = 1;
}
Personal tools
Mongers