Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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`;

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

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
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 Perl.com.

    Makeshifts last the longest.

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`;
    nfytn@rasmus.uib.no

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://201436]
Approved by krujos
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-07-30 21:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (240 votes), past polls