#!/usr/bin/perl use strict; use warnings; use Tie::File; tie my @tied_array, 'Tie::File', 'tiefile' or die "Could not tie to tiefile: $!"; push(@tied_array, $_) for (1..3); print "\@tied_array has " . scalar @tied_array . " elements before sorting\n"; @tied_array = sort {uc($a) cmp uc($b)} @tied_array; print "\@tied_array has " . scalar @tied_array . " elements after sorting\n"; untie @tied_array; #### ~/dev/perl$ perl test_tie_file.pl @tied_array has 3 elements before sorting @tied_array has 4 elements after sorting ~/dev/perl$ perl test_tie_file.pl @tied_array has 7 elements before sorting @tied_array has 8 elements after sorting ~/dev/perl$ perl test_tie_file.pl @tied_array has 11 elements before sorting @tied_array has 12 elements after sorting ~/dev/perl$ cat tiefile 1 1 1 2 2 2 3 3 3 ~/dev/perl$