rational_icthus has asked for the wisdom of the Perl Monks concerning the following question:
my $r = { subref => sub { return 2 * $_[0] } }; my $tied; tie $tied, 'TieTest', $r; # This will perform the pre-action before executing print $tied->(5); # These will not for(0..100){ print $tied->(5), "\n"; } package TieTest; sub TIESCALAR{ my $caller = shift; my $r = shift; bless $r, $caller; } sub FETCH{ my $r = shift; print "Checking for pause...\n"; return $$r{subref}; }
This prints the "extra" message plus a "CODE(0x224e2c)". So FETCH only fails when I attempt to dereference the returned subref.# This will perform the pre-action before executing print $tied; # These will not for(0..10){ print $tied, "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Wierd Behavior With Tie
by dragonchild (Archbishop) on Jun 02, 2006 at 04:45 UTC | |
by rational_icthus (Sexton) on Jun 02, 2006 at 17:36 UTC | |
|
Re: Wierd Behavior With Tie
by Joost (Canon) on Jun 02, 2006 at 00:58 UTC | |
|
Re: Wierd Behavior With Tie
by japhy (Canon) on Jun 02, 2006 at 00:35 UTC | |
|
Re: Wierd Behavior With Tie
by Limbic~Region (Chancellor) on Jun 02, 2006 at 18:26 UTC | |
by rational_icthus (Sexton) on Jun 02, 2006 at 19:42 UTC | |
by Limbic~Region (Chancellor) on Jun 03, 2006 at 15:45 UTC | |
by ikegami (Patriarch) on Jun 02, 2006 at 19:37 UTC | |
by Limbic~Region (Chancellor) on Jun 03, 2006 at 15:48 UTC | |
by ikegami (Patriarch) on Jun 03, 2006 at 20:12 UTC | |
|
Re: Wierd Behavior With Tie
by ikegami (Patriarch) on Jun 02, 2006 at 17:54 UTC | |
by rational_icthus (Sexton) on Jun 02, 2006 at 18:19 UTC | |
by ikegami (Patriarch) on Jun 02, 2006 at 19:40 UTC | |
by rational_icthus (Sexton) on Jun 02, 2006 at 22:49 UTC |