in reply to Cropping Elements in an Array

Hideously untested but you should get the idea:
for (@yourarray) { chomp; # maybe my @ary = split / /, $_; for (0..1) { pop @ary; } print "@ary\n"; }

Replies are listed 'Best First'.
RE: RE: Cropping Elements in an Array
by chromatic (Archbishop) on Nov 02, 2000 at 21:27 UTC
    Go one step further:
    for (@yourarray) { my @ary = (split/ /, $_, 5)[0 .. 4]; }
    or even the also untested:

    @yourarray = map { join(" ", (split(/ /, $_))[0 .. 4]) } @yourarray;


      I was trying to avoid the slice of the first few, I don't know why ;-), I fancied lopping two items off the end.
      too lazy to use splice......
      splice(@ary, -2);