#!/usr/bin/perl -w
use strict;
my @color = qw(red green blue cyan);
exec 'aterm',
qw(-fg green -tr -trsb),
-tint => $color[rand @color],
qw(-cr green -pr green -bd green);
You don't need all those temporary variables; strive to minimize their amounts. strict and warnings should be a habit you don't even need to think about.
That's just style though, the actual improvement would be dropping the backticks which spawn a new process, start a shell in it and have it run your program, capturing its output and returning it. All that for naught, since you're not using the output. Save two processes, a bunch of memory and a shell call (which should always be avoided when possible) by exec()ing instead. You don't need to have control returned from the external program anyway.
For some general hints on good programming habits, see Mark-Jason Dominus' excellent Program Repair Shop and Red Flags article series on Perl.com.
Makeshifts last the longest. |