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

lodin's scratchpad

by lodin (Hermit)
on Aug 19, 2007 at 11:24 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2024-10-10 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (45 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.