Switch.pm

josh hoblitt jhoblitt at mysun.com
Thu Jul 11 18:07:22 CDT 2002


I agree that this works... but it doesn't make the code any cleaner to
read then using a bunch of if statements.

I think this falls into the...

"If my dog was that ugly I'd shave it's ass and make it walk backwards".

Department.

-J
> 
> $foo='foobar';
> 
> $_=$foo;
> SWITCH: {
>  /oo/ && do {
>    print "found foo\n";
>  };
>  /(b)a/ && do {
>    print "found ba\n";
>    print "\$1: $1\n";
>    # This is equivalent to 'break' in C.
>    last SWITCH;
>  };
>  /r/ && do {
>    print "r\n";
>  };
>  # Default here
> }
> 

TIMTOWTDI



More information about the Pdx-pm-list mailing list