Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Switch (module) and Apache::Registry problem.

by nevyn (Monk)
on Oct 30, 2003 at 17:36 UTC ( [id://303339]=note: print w/replies, xml ) Need Help??


in reply to Switch (module) and Apache::Registry problem.

Well if you really like the look of the switch type construct, TIMTOWTDI...

SubSwitch.pm

package SubSwitch; use strict; use base 'Exporter'; our @EXPORT_OK = qw( switch case ); our $SubSwitch = undef; sub switch { my ($val, $func) = @_; local $SubSwitch = $val; $func->(); } sub case { my ($val, $func) = @_; if ($val ne $SubSwitch) { return; } $func->(); } 1;

test.pl

#! /usr/bin/perl -w use strict; use SubSwitch qw(switch case); switch ("foo", sub { case ("bar", sub { print "not here\n"; }); case ("foo", sub { print "here\n"; switch ("bar", sub { case ("bar", sub { print "there\n"; }); }); }); case ("bar", sub { print "still not here\n"; }); })
--
James Antill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://303339]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-03-19 08:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found