From b60650580f609070b092a82d778ad53514402965 Mon Sep 17 00:00:00 2001 From: Harvie Date: Tue, 28 Sep 2010 22:37:46 +0200 Subject: [PATCH] Ported 10-menu.pl to PERL v5.10 --- purple/answerscripts.d/10-menu.pl | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) 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' } } } -- 2.30.2