All pastes #591881 Raw Edit

Mine

public text v1 · immutable
#591881 ·published 2007-06-27 13:38 UTC
rendered paste body
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();
}