Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Return::DataButBool 0.0.3

    Download button

    No screenshots available
    Downloads: 219  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Daniel Muey | More programs
    Perl Artistic License / FREE
    November 16th, 2009, 02:51 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    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
     }
     }



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    boolean value | numeric value | string value | boolean | numeric | string

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM