Ported 10-menu.pl to PERL v5.10
authorHarvie <tomas@mudrunka.cz>
Tue, 28 Sep 2010 20:37:46 +0000 (22:37 +0200)
committerHarvie <tomas@mudrunka.cz>
Tue, 28 Sep 2010 20:37:46 +0000 (22:37 +0200)
purple/answerscripts.d/10-menu.pl

index 40f22b4b2bd57e74daac0c22451bd5d7a75ae750..d055f84eaa7cb6d1f421d21a4852d46f2e3ba8a5 100755 (executable)
@@ -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' } }
 }
This page took 0.147373 seconds and 4 git commands to generate.