#!/usr/bin/perl use strict; use warnings; use Tie::File; my $file = '/path/to/file.txt'; tie my @array,'Tie::File',$file or die $!; @array = sort{$a cmp $b}@array; print $_,"\n" for(@array); untie @array;