Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Konversation script

Status
Not open for further replies.

krammer

IS-IT--Management
Jul 15, 2007
59
US
I have made a perl script for the IRC Linux kde client "Konversation." What I want to do it modify this script so it uses a different smiley face depending on the month. So in October the smiley face would be orange, or december it would be green and red. Here is what I have, thanks to anyone who can help...

Code:
#!/usr/bin/env perl

# colored smile script for konversation
# has been tested on debian


$PORT = shift;
$SERVER = shift;
$TARGET = shift;


exec 'dcop', $PORT, 'default', 'say', $SERVER, $TARGET, "%B%C3: %C4)%C%B"
 
would it be more efficient (definitely would be harder to read) to just use an array then?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
ahh, he figured it out. This line:

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

can be changed to:

$mon = (localtime)[4];

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Travis,

I am not sure if it would be more efficient or not. But it could be done with arrays instead of hashes.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
: )

Well it works! I probably won't be doing much more with it...thank you for all the help.
 
KevinADC said:
I am not sure if it would be more efficient or not. But it could be done with arrays instead of hashes.
Since the hash keys are integers starting at 0, it would have the same effect to use an array and would indeed be more efficient.
 
If it were a large hash I would recommend you use an array in this situation, but it is such a small hash the difference has to be very slight between an array or hash. For any practical purposes there would be no difference, but if you had to write the most optimized code then an array might earn you a better grade.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top