use warnings; use strict; my %lines; while (<DATA>) { my ($num) = $_ =~ /(\d+)$/; $lines{$num} = $_; } for (sort {$a <=> $b} keys %lines) { print $lines{$_}; } __DATA__ foo bar 4 goo 1 hoo boo boo 2 yeah 3
Outputs:
goo 1 hoo boo boo 2 yeah 3 foo bar 4
In reply to Re: Print to specific line
by toolic
in thread Print to specific line
by perlUser345
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |