Programmer Efficiency
The half-perfect program that you can run today is better than the fully perfect and pure program that you can run next month. Deal with some temporary ugliness.[205] Some of these are the antithesis of our advice so far.
Look on CPAN before you write your own code.
Look on CPAN again. You probably missed the module you need. Ask around.
Use defaults.
Use funky shortcut command-line switches like
–a,–n,–p,–s, and–i.Use
forto meanforeach.Run system commands with backticks.
Use
<*>and such.Use patterns created at runtime.
Use
*,+, and{}liberally in your patterns.Process whole arrays and slurp entire files.
Use
getc.Use
$`,$&, and$'.Don’t check error values on
open, since<HANDLE>andprintHANDLEwill simply behave as no-ops when given an invalid handle.Don’t
closeyour files—they’ll be closed on the nextopen.Don’t pass subroutine arguments. Use globals.
Don’t name your subroutine parameters. You can access them directly as
$_[EXPR].Use whatever you think of first.
Get someone else to do the work for you by programming half an implementation and putting it on Github.
[205] This is also called “technical debt”, but it’s not always a bad thing.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access