Return::DataButBoolReturn a boolean value that also has arbitrary numeric and string values | |
Download |
Return::DataButBool Ranking & Summary
Advertisement
- License:
- Perl Artistic License
- Price:
- FREE
- Publisher Name:
- Daniel Muey
- Publisher web site:
- http://search.cpan.org/~dmuey/
Return::DataButBool Tags
Return::DataButBool Description
Return a boolean value that also has arbitrary numeric and string values Perl's Zero-But-True ( 0e0 ) is a most handy tool (See String::ZeroButTrue). Return::DataButBool is a Perl module that expands on that idea by having a return value that has different boolean, numeric, and string values.For example you could return a count of files processed (say 42 which is "true") but still say it failed in boolean context.or you could return any false value ( not just '0' ) but still return true. The flexibility allows for all sorts of use.SYNOPSIS use Return::DataButBool; sub whatever { ... return $ok ? data_but_true( $count ) : data_but_false( $count, $error ); }later in the code using this function: my $total = 0; for my $thing ( @stuff ) { my $rc = whatever( $thing ); $total += $rc; # numeric value if( !$rc ) { # boolean value carp "Error happened: $rc"; # string value } } Requirements: · Perl
Return::DataButBool Related Software