syphilis has asked for the wisdom of the Perl Monks concerning the following question:
The aim is to be able to determine whether a subroutine call changes the status of any of those flags on the subroutine's argument. That is:sub flag_status { my $v = $_[0]; return is_IOK($v) | is_pIOK($v) | is_IsUV($v) | is_NOK($v) | is_pNOK($v); } sub is_IOK { # return 1 if argument's IOK flag is set # else return 0 } sub is_pIOK { # return 2 if argument's pIOK flag is set # else return 0 } sub is_NOK { # return 4 if argument's NOK flag is set # else return 0 } sub is_pNOK { # return 8 if argument's pNOK flag is set # else return 0 } sub is_IsUV { # return 16 if argument's IsUV flag is set # else return 0 }
Is there already a perl module that ships with the core that will return the status of those 5 flags ?my $d = 2.7; my $flags_prior = flag_status($d); foo($d); my $flags_after = flag_status($d); die "foo() altered its argument's numeric flags" if($flags_prior != $flags_after);
|
---|