Archive for the 'Perl' Category

Perl snippets

Monday, March 19th, 2007

Sort numeric table:
my @tab = sort { $a <=> $b } @{ $results->{$transaction} };

Create classes:
sub new {
my $class = shift;
my $self = { %OPTIONS, @_ };
return bless $self, ref $class || $class;
}

Useful one-liner:
my $sum = eval(join "+", @tab);