toxic ! Mr. Yuck! map & grep => transformers "More than meets the eye!" @humped = grep { $humped{$_} } @animals; Complexity of a program is a function of: length of program reading stack depth (mean and max) reader understanding of the problem reader familiarity with the language And is measured by time to read the program with comprehension OK. So? shell out - use your OS it has lots of swiss army knife programs use the preset variables $_, @_ use as few declarations and assignments as possible polluting the namespace of perl isn't the worry polluting the reader's namespace is. e.g. fibonacci. organize data into structures if your code looks like yank-put monkey p00 you probably need another data structure e.g. eval minimize consecutive reader stack pushes keep related code together use scoping to containerize code and variables and false scoping too e.g. regexp give the reader a mental model of how your program works this is documentation (Aaaaauugh!) stick to your style manual what constructs should the reader be familiar with? put the important stuff first ;) e.g. and, or, if Cool things: map => handles one-to-one or one-to-many mappings # this also minimizes namespace pollution for our reader @transactions = map { `grep TRANSACTION $_` } ( @ARGV or `ls $logdir` ); unix => lots of useful programs with man pages eval => create code on the fly to separate code from data %actions = ( accepted_charges => '$test1 eq "CHARGE" and $test2 eq "OK"', rejected_charges => '$test1 eq "CHARGE" and $test2 eq "NOK"', accepted_refunds => '$test1 eq "REFUND" and $test2 eq "OK"', rejected_refunds => '$test1 eq "REFUND" and $test2 eq "NOK"', ); ... for (keys %actions) { eval($actions{$_}) and $count{$_}++; } false scoping => use indents to hide documentation variables # this also reduces reader stack usage my $regexp = qr|$id \t $type \t $status \t $amount|x if ( my $id = qr|\d+|, my $type = qr|(CHARGE|REFUND)|, my $status = qr|(OK|NOK)|, my $amount = qr|(\d+\.\d\d)|, ); and/or => allow you to put the important stuff first on the line # 'A and B' is the same logic as if A then B. Why? # see 'if' in the above example for (@transactions) { /$regexp/ and do { summarize($1,$2,$3); next }; /.*/ and do { print }; }