[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 2/7] vtpmmgr: add example control tools



Ian Campbell writes ("Re: [Xen-devel] [PATCH 2/7] vtpmmgr: add example control 
tools"):
> On Wed, 2014-03-19 at 15:52 -0400, Daniel De Graaf wrote:
> A trick I learnt from osstest.git:mg-hosts:
>         die unless @ARGV;
>         my $subcmd= shift @ARGV;
>         $subcmd =~ s/-/_/g;
>         my $subcmdproc;
>         {
>             $subcmdproc= \&{ "cmd_$subcmd" };
>         }
>         $subcmdproc->();
> 
> (not sure what those braces do, Ian?)

I think they were there to contain the scope of
   no strict qw(refs);
which is mysteriously absent.

...

So it turns out, on experimenting and RTFM, that "use strict" doesn't
affect subroutine refs.  So the braces are unnecessary.


Also, since I wrote that I have been using a better idiom:

    my $funcn = $method;
    $funcn =~ y/-/_/;
    my $mainfunc = $main::{"main__$funcn"};
    reject "unknown method" unless $mainfunc;
    #...
    &$mainfunc

This makes it possible to print a sensible error message.

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.