Next Tricks of the Wizards 55

Tied Scalar Example

        use Sequence;
        tie $IDS => Sequence, 17;        # $IDS is special now
        $id = $IDS;                      # $id is now 17
        $another = $IDS;                 # $another is now 18
        print $IDS, "\n";                # Prints 19
        push @ids, $IDS;                 # Pushes 20        
        $IDS = 17;                       # Reset to 17


Next Copyright © 2003 M. J. Dominus