On Nov 14, 2010, at 4:36 AM, C.DeRykus wrote: > And now it seems a little bit > inelegant to redefine the closure each time through > the loop. > > > for my $flags ( ... ) { > my $mask = sub { return ($flags & $_[0]) == $_[0] }; > given( $flags ) { > when ( $mask->($one_and_three) ) { ... } > when ( $mask->($zero_and_four) ) { ... } > ... > } > ...
First, thanks for (($flags & $mask) == $mask). What I eventually did was just call a subroutine on($flags, $mask) to do the calculation and determine whether all the specified bits were on. Seems simpler than the closure technique, even if having to repeatedly write '$flags' is less than ideal. However, now I'm determined to get an understanding of closures, and I see another thread on this list that provides several links to help in that regard. Thanks, one and all! Regards, Chap -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/