perl - exit a switch case from within a subroutine -
I wonder how to leave the switch matter from a substrate like this:
#! Use the / usr / bin / perl switch; Switch ($ command) {case 'create_vmr' {... do something ... callbank ($ bubla); ... do something else ...} case 'delete_vmr' {... do something ... callbank ($ bubla); ... do something else ...}} ... last code ... exit (0); Sub-callbo ... ... Check something ... last $ $ condition; } I thought, 'the last' in the callb () comes out of the case which was told to it, so that the code can proceed after the switch element. But it does not work
So, how can I leave the element switch from a sub?
Edit: And I do not want to use 'Geto';)
I will not try to break through the obscurity of my program.
Instead, if it succeeds, and the sub-routines return a true value by breaking the calling code block.
In this example, I should show a Dispatchable Table Switch module:
Use strict; Use warnings; My% send = (create_vmr = & gt; sub {# ... something ... the callb ('FU') or return; # ... do something else ...}, deleted _vmr = & gt; sub {# .. Do something ... callb ('bar') or return; # ... do something else ...},); My $ command = 'delete_vmr'; If ($ remittance {$ command}) {$ remittance {$ command} (); } Other {Warning "unknown $ command"; } Exit (0); Sub callbank {# ... check something ... return $ _ [0] eq 'afoo'; }
Comments
Post a Comment