Another way to do it: instead of splitting everything and then ignoring some of it, find and split only the stuff you want.
use strict; use warnings; my $str = "discard\ndiscard\nkeep1\nkeep2"; my $discard = 2; my @arr = ($str =~ /^(?:[^\n]*\n){$discard}(.*)/s ? split /\n/, $1 : ( +) ); print "@arr";
In reply to Re: Last index use in array slice
by ColonelPanic
in thread Last index use in array slice
by ltp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |