#!/usr/bin/perl use strict; use warnings; open my $input, '<' or die "Unable to open input file: $!"; my @file = <$input>; my @sorted_file = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { my ($x) = $_ =~ /VerNumber:\((\d+)/i; [$_, $x]; } @file; open my $output, '>' or die "Unable to open output file: $!"; print $output $_ for @sorted_file;