in reply to Need some data structures cooked

#!/usr/bin/perl use strict; use simplegraph; $iteration = 0; $servers={'64.210.209.50' => { domain => 'www.zwire.com', scale => 3500, vips => [], }, '64.210.209.51' => {}, };
Trap your errors .. and link/unlink.

splice (@{$vips{$k}{'stack'}},0,$#{$vips{$k}{'stack'}}-50) if ($#{$vip +s{$k}{'stack'}}>50);
Hope this helps
UnderMine

Replies are listed 'Best First'.
Re: Re: Need some data structures cooked
by petral (Curate) on Nov 21, 2002 at 15:55 UTC
    Well cooked!  Oddly enough, all you need is:    splice @{$vips{$k}{'stack'}}, 0, -50; It will leave the array untouched if it is not greater than 50.
    $ perldoc -f splice . . . If LENGTH is negative, leaves that many elements off the end of the + array.
    (I guess they mean "off the deleted array" -- at all events, that's how it works (and also what makes sense).  It's explained clearly here!)

      p