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.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Want 0.18

    Download button

    No screenshots available
    Downloads: 310  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.8/5)
    5 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Robin Houston | More programs
    Perl Artistic License / FREE
    February 4th, 2008, 17:49 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Want description

    Want is a Perl module created to implement the `want' command.

    Want is a Perl module created to implement the `want' command.

    SYNOPSIS

    use Want;
    sub foo :lvalue {
    if (want(qw'LVALUE ASSIGN')) {
    print "We have been assigned ", want('ASSIGN');
    lnoreturn;
    }
    elsif (want('LIST')) {
    rreturn (1, 2, 3);
    }
    elsif (want('BOOL')) {
    rreturn 0;
    }
    elsif (want(qw'SCALAR !REF')) {
    rreturn 23;
    }
    elsif (want('HASH')) {
    rreturn { foo => 17, bar => 23 };
    }
    return
    }

    This module generalises the mechanism of the wantarray function, allowing a function to determine in some detail how its return value is going to be immediately used.

    ...

    EXAMPLES

    use Carp 'croak';
    use Want 'howmany';
    sub numbers {
    my $count = howmany();
    croak("Can't make an infinite list") if !defined($count);
    return (1..$count);
    }
    my ($one, $two, $three) = numbers();


    use Want 'want';
    sub pi () {
    if (want('ARRAY')) {
    return [3, 1, 4, 1, 5, 9];
    }
    elsif (want('LIST')) {
    return (3, 1, 4, 1, 5, 9);
    }
    else {
    return 3;
    }
    }
    print pi->[2]; # prints 4
    print ((pi)[3]); # prints 1


    sub backstr :lvalue {
    if (want(qw'LVALUE ASSIGN')) {
    my ($a) = want('ASSIGN');
    $_[0] = reverse $a;
    return undef;
    }
    elsif (want('RVALUE')) {
    my $t = scalar reverse $_[0];
    }
    else {
    carp("Not in ASSIGN context");
    }
    return
    }

    print "foo -> ", backstr("foo"), "n"; # foo -> oof
    backstr(my $robin) = "nibor";
    print "$robin is now $robinn"; # $robin is now robin

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    implement want | want command | Perl module | Want | implement | want

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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