Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

lodin's scratchpad

by lodin (Hermit)
on Aug 19, 2007 at 11:24 UTC ( #633591=scratchpad: print w/replies, xml ) Need Help??

tie issue:

use strict; # When array dereferencing a tied scalar it seems like # it gets stuck. { package FirstElem; sub TIESCALAR { my $class = shift; my ($list) = @_; return bless \$list => $class; } sub FETCH { ${$_[0]}->[0] } } my @plain = 'a' .. 'z'; my @arefs = map [ $_ ], @plain; tie my $plain, FirstElem::, \@plain; tie my $arefs, FirstElem::, \@arefs; shift @plain; print $plain; # b shift @plain; print $plain; # c shift @plain; print $plain; # d shift @plain; print $plain; # e print "\n"; shift @arefs; print @$arefs; # b shift @arefs; print @$arefs; # b, should be c shift @arefs; print @$arefs; # b, should be d, my $copy = $arefs; # This updates it, @$arefs is now d. shift @arefs; print @$arefs; # d, should be e __END__ Output: bcde bbbd
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2021-04-10 12:16 GMT
Find Nodes?
    Voting Booth?

    No recent polls found