This kind of flexibility in a switch statement reminds me why I love perl.
Sam Gardner
GTO Application Development
Keefe, Bruyette & Woods, Inc.
212-887-6753
-----Original Message-----
From: Thomas, Mark - BLS CTR [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 13, 2005 10:46 AM
To: 'John Deighan'; [email protected]
Subject: RE: Change in "goto" behavior
John Deighan wrote:
> We have a goto in our code. I hate it, but there just isn't a good
"switch" or "case" statement in Perl yet
Yes there is, in Perl 5.8. If you're using an older Perl, you can still get Switch.pm from CPAN.
use Switch;
switch ($val) {
case 1 { print "number 1" }
case "a" { print "string a" }
case [1..10,42] { print "number in list" }
case (@array) { print "number in list" }
case /\w+/ { print "pattern" }
case qr/\w+/ { print "pattern" }
case (%hash) { print "entry in hash" }
case (\%hash) { print "entry in hash" }
case (\&sub) { print "arg to subroutine" }
else { print "previous case not true" }
}
_______________________________________________
Perl-Win32-Users mailing list [email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
