in reply to Unique entries from an array

All the image locations are are read into an array from a text file.

Rather that having to rework the values you entered into your array, don't read them into an array in the first place--use a hash instead.

use strict; use warnings; use 5.010; my %pics; while (<DATA>) { chomp; $pics{$_} = 1; } my @unique_names = keys %pics; foreach (@unique_names) { say; } __DATA__ /a/b/img1.jpg /a/b/img1.jpg /a/b/img2.jpg /x/y/img2.jpg /x/y/img2.jpg /x/y/img3.jpg

--output:--

/a/b/img2.jpg /a/b/img1.jpg /x/y/img3.jpg /x/y/img2.jpg