From: Harvie Date: Tue, 28 Sep 2010 20:37:46 +0000 (+0200) Subject: Ported 10-menu.pl to PERL v5.10 X-Git-Url: http://git.harvie.cz/?p=mirrors%2Flibpurple-core-answerscripts.git;a=commitdiff_plain;h=b60650580f609070b092a82d778ad53514402965;hp=64ac1ebfdbe2d4c515b626b23bb172eb01b2bb39 Ported 10-menu.pl to PERL v5.10 --- diff --git a/purple/answerscripts.d/10-menu.pl b/purple/answerscripts.d/10-menu.pl index 40f22b4..d055f84 100755 --- a/purple/answerscripts.d/10-menu.pl +++ b/purple/answerscripts.d/10-menu.pl @@ -2,16 +2,16 @@ #Just for you to see that you can use almost any language :-) use strict; use warnings; -use Switch; +use v5.10; #given/when (if you need to use older PERL, you can find older version in GIT) -switch ($ENV{ANSW_MSG}) { - case /^!help$/ { print qx{ grep -o 'case /[^\$/]*' "$0" | grep -o '!.*' | tr '\n' ',' }; } - case /^!ping$/ { print "PONG"; } - case /^!whoami$/ { print "You are: $ENV{ANSW_FROM}"; } - case /^!status$/ { print "[$ENV{ANSW_STATUS}] $ENV{ANSW_STATUS_MSG}"; } - case /^!(reboot|reset|restart|halt)$/ { print "Broadcast message: The system is going down for reboot NOW !!"; } - case /^!google/ { print "UTFG Yourself: http://google.com/"; } - case /^!uptime$/ { print qx{uptime}; } - case /^!date$/ { print qx{date}; } - case /^!dmesg$/ { print qx{ dmesg | tail -n 5 | tr '\n' '\t' } } +given ($ENV{ANSW_MSG}) { + when (/^!help$/) { print qx{ grep -o 'when \(/[^\$/]*' "$0" | grep -o '!.*' | tr '\n' ',' }; } + when (/^!ping$/) { print "PONG"; } + when (/^!whoami$/) { print "You are: $ENV{ANSW_FROM}"; } + when (/^!status$/) { print "[$ENV{ANSW_STATUS}] $ENV{ANSW_STATUS_MSG}"; } + when (/^!(reboot|reset|restart|halt)$/) { print "Broadcast message: The system is going down for reboot NOW !!"; } + when (/^!google/) { print "UTFG Yourself: http://google.com/"; } + when (/^!uptime$/) { print qx{uptime}; } + when (/^!date$/) { print qx{date}; } + when (/^!dmesg$/) { print qx{ dmesg | tail -n 5 | tr '\n' '\t' } } }