in reply to Re: Split a variable at a Given Line-Number
in thread Split a variable at a Given Line-Number
$txt=join "\n",0..99; print join "\n", (split /\n/, $txt, -1 )[-5 ..-1];
OUT
95 96 97 98 99
Cheers Rolf
UPDATE:
This handles the case of #slicelines > #textlines
print join "\n",grep {defined} (split /\n/,$txt,-1 )[-16 ..-1]
UPDATE: added -1 to handle trailing empty lines, but I suppose thats not intended in this usecase.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Split a variable at a Given Line-Number
by LanX (Saint) on May 18, 2010 at 13:36 UTC | |
by moritz (Cardinal) on May 18, 2010 at 13:39 UTC | |
by LanX (Saint) on May 18, 2010 at 13:42 UTC |