in reply to Re^2: Cutting text from the end of the file and adding it to the top
in thread Cutting text from the end of the file and adding it to the top
So, you are saying that the numbers in the input are essentially irrelevant. SSCCE:
#!/usr/bin/env perl use strict; use warnings; my @lines = <DATA>; print shift @lines; chomp @lines; my $perline = 8; my @num; my @numline = (1 .. $perline); my $fmt = '%s ' . '%5i' x $perline . "\n"; for my $line (@lines) { if ($line =~ /^1/) { print join (' ', @num) . "\n"; last; } printf $fmt, $line, @numline; push @num, @numline; $_ += $perline for @numline; } __DATA__ a b c d e f g h aa bb cc dd aa bb cc dd aa bb cc dd 1 2 3 4 5 6 7 8 9 10 11 12 13 1 +4 15 16
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Cutting text from the end of the file and adding it to the top
by oysterperl (Novice) on Sep 30, 2019 at 10:34 UTC | |
by poj (Abbot) on Sep 30, 2019 at 11:54 UTC | |
by Utilitarian (Vicar) on Sep 30, 2019 at 12:21 UTC | |
by oysterperl (Novice) on Oct 01, 2019 at 05:26 UTC | |
by AnomalousMonk (Archbishop) on Oct 01, 2019 at 06:10 UTC | |
by oysterperl (Novice) on Oct 07, 2019 at 09:50 UTC |