#!/usr/bin/perl use strict; use warnings; open(F, "file.txt") or die $!; my @file = ; close(F); @file = sort{$a cmp $b} @file; print @file;