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

    Tie::Scalar::Sticky 1.06

    Download button

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

    License / Price:

    Last Updated:

    Category:
    Jeffrey Hayes Anderson | More programs
    Perl Artistic License / FREE
    February 14th, 2007, 05:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Tie::Scalar::Sticky description

    Tie::Scalar::Sticky is a Perl module with block assignments to scalars.

    Tie::Scalar::Sticky is a Perl module with block assignments to scalars.

    SYNOPSIS

    use strict;
    use Tie::Scalar::Sticky;

    tie my $sticky, 'Tie::Scalar::Sticky';

    $sticky = 42;
    $sticky = ''; # still 42
    $sticky = undef; # still 42
    $sticky = 0; # now it's zero

    tie my $sticky, 'Tie::Scalar::Sticky' => qw/ foo bar /;

    $sticky = 42;
    $sticky = 'foo'; # still 42
    $sticky = 'bar'; # still 42
    $sticky = 0; # now it's zero

    Scalars tie'ed to this module will 'reject' any assignments of undef or the empty string or any of the extra arugments provided to tie(). It simply removes the need for you to validate assignments, such as:

    $var = $val unless grep $val eq $_, qw(not one of these);

    Actually, that is the exact idea used in this module ...
    So, why do this? Because i recently had to loop through a list where some items were undefined and the previously defined value should be used instead. In a nutshell:

    tie my $sticky, 'Tie::Scalar::Sticky' => 9, 'string';
    for (3,undef,'string',2,'',1,9,0) {
    $sticky = $_;
    print $sticky, ' ';
    }

    Should print: 3 3 2 2 1 0

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    block assignments | scalars assignments | Perl module | Tie::Scalar::Sticky | scalars | block

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

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