Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

aterm script

by mr2 (Friar)
on Sep 28, 2002 at 10:33 UTC ( #201436=CUFP: print w/replies, xml ) Need Help??

i wrote a usefull (at least for me) perl script that executes aterm with flags where the -tint $color flag everytime you execute the script changes ... so everytime you open a new aterm window ... it has a random tint color...

any suggestions on making the script better are wellcome.

#!/usr/bin/perl my @colors = ( 'red', 'green', 'blue', 'cyan' ); $howmany=@colors; $color = @colors[abs(rand($howmany))]; $line = 'aterm -fg green -tr -trsb -tint '."$color".' -cr green -pr gr +een -bd green +sb'; `$line`;

Replies are listed 'Best First'.
Re: aterm script
by Aristotle (Chancellor) on Sep 28, 2002 at 22:21 UTC
    #!/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

    Makeshifts last the longest.

(jeffa) Re: aterm script
by jeffa (Bishop) on Sep 28, 2002 at 21:16 UTC
    use strict; my @color = qw(red green blue cyan); my $color = $color[rand @color]; ...


    (the triplet paradiddle with high-hat)
Re: aterm script
by Anonymous Monk on Nov 01, 2002 at 17:07 UTC
    More choice. And is this ugly :)
    #!/usr/bin/perl my @colors = (split (/\n/,`cat /usr/lib/X11/rgb.txt |awk '{print \$4}' +`) ); $howmany=@colors; $color = @colors[abs(rand($howmany))]; $line = 'aterm -fg green -tr -trsb -tint '."$color".' -cr green -pr gr +een -bd green +sb'; `$line`;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://201436]
Approved by krujos
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-02-20 22:40 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (304 votes). Check out past polls.