I have a file that looks like:
text text text text : 6 min
text text text text : 2 min
text text text text : 8 min
text text text text : 2 min
I need to sort this file to get that output :
text text text text : 2 min
text text text text : 2 min
text text text text : 6 min
text text text text : 8 min
I tried to do this but it doesn't work :
my @copy = ();
open (INFILE, $ARGV[0]);
while (<INFILE>) {
push (@copy, $_);
}
my @lines = sort grep /^: (\d+) min/ , @copy;
print @lines;
Is there any easy way to do this in perl ?