in reply to Split a variable at a Given Line-Number
use List::Util qw(max); my @lines = split /\n/, $str; my $prefix = join "\n", @lines[0..@lines-16]; my $postfix = join "\n", @lines[max(0, @lines-15)..$#lines];
(Update: fixed offby1 error)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Split a variable at a Given Line-Number
by LanX (Saint) on May 18, 2010 at 12:55 UTC | |
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 | |
|
Re^2: Split a variable at a Given Line-Number
by danj35 (Sexton) on May 18, 2010 at 13:40 UTC |