thanks but even if the code below runs well with all your improvements, as soon as i add a simply print "\@arr [@arr]\n"; at the end, the program hangs, eating a lot of memory. I dont understand why.
use strict; use warnings; sub trigger{print "Triggered: ",map {defined $_ ? " $_" : 'UNDEF'}@_," +\n"} { package Arraytrigger; use Tie::Array; use vars qw(@ISA); @ISA = ('Tie::StdArray'); for (qw(STORE CLEAR PUSH POP SHIFT UNSHIFT)) { my $s = "SUPER::$_"; no strict 'refs'; *$_ = sub { &main::trigger; shift()->$s(\@_) }; } } #package main.. tie my @arr, 'Arraytrigger'; print "\tSetting list:\n" and @arr = qw(a b c d e); #print "\tSetting one:\n" and $arr[0]=0; #print "\tpushing:\n" and push @arr,'f'; #print "\tpopping:\n" and pop @arr; #print "\tshifting:\n" and shift @arr; #print "\tunshifting:\n" and unshift @arr, 'zero'; #print "\tclearing with undef \@arr:\n" and undef @arr; #print "\tSetting list:\n" and @arr = qw(a); #print "\tSetting list:\n" and @arr = qw(a); #print "\tclearing with \@arr=():\n" and @arr=(); #my $ref = \$arr[0]; #print "\tsetting by reference:\n" and $$ref=11; #print "\tclearing:\n" and @arr=();#undef @arr and @arr=undef se +em no good..e # print "\@arr [@arr]\n"; #use Data::Dump;print dd(@arr);
thanks
L*
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re^3: tie example.. Code still hangs by Discipulus
in thread Is tie inteded to be used in this way? by Discipulus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.