in reply to Re: Getting range from N..end with list slice
in thread Getting range from N..end with list slice

Good thought. The problem is that this doesn't scale very well. Some of these files can have lines with hundreds of fields. I'm working with file like that now and I wouldn't be surprised if I find some field that means "name of user's first dog"! :)

Something like this would scale better and run fast, but of course it is two statements and doesn't use list slice.

my $x = "a b c d e f g h"; my @set = (split /\s+/, $x); splice(@set,0,3); print "@set\n"; #prints d e f g h

Replies are listed 'Best First'.
Re^3: Getting range from N..end with list slice
by JavaFan (Canon) on Nov 27, 2010 at 13:29 UTC
    Personally, I wouldn't fret on it. If the point is you want to do it all in one statement:
    my @set = (split /\s+/, $x)[3 .. -1 + split /\s+/, $x];
    But that splits twice.