in reply to Sort passwd by UID

You have slurped all your input lines into the 1st element of the @array variable. Here's how I would do it:
use warnings; use strict; use File::Slurp; my $file = '/etc/passwd'; my @lines = read_file($file); chomp @lines; my @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1] || $a->[1] cmp $b->[1]} map {[$_,(split':')[0]]} @lines; print "$_\n" for @sorted;