in reply to Print to specific line
G'day perlUser345,
Welcome to the Monastery.
Here's one way to do it:
#!/usr/bin/env perl -l use strict; use warnings; no warnings 'uninitialized'; my @out_records; my $re = qr{ ^ ( .* ) \s ( \d+ ) $ }x; /$re/ and $out_records[$2 - 1] = $1 while <DATA>; print for @out_records; __DATA__ Line 5 5 Line 1 1 Line 3 3
Output:
$ pm_1131675_order_out_by_input_spec.pl Line 1 Line 3 Line 5
-- Ken
|
|---|