my %actions = (
"read" => \&trGet,
"write" => \&trGet,
"init" => \&trInit,
"help" => \&help,
);
#$flag is global, and used in each fucntion
my $flag = shift @ARGV;
&usage () unless defined $flag;
$actions{"$flag"} -> ();
sub usage {
print<<USAGE;
read:
-interface <interface name> <value>
-wlan <value>
write:
help:
USAGE
exit(1);
}
sub trGet {
#Dummy function, just read the next argument and execute the function
my $func = shift @ARGV;
my $funcref = \$func;
(print "Specify an action\n" and exit) if !defined $func;
#execute the reference to the function
&$$funcref();
}