#!/usr/bin/perl -w use strict; my @imgs; while (my $path = ) { chomp $path; my ($fullname, $name, $ext) = $path =~ m#(([^/]+)\.(\w+))$#; my $type = "image/$ext"; $type =~ s/jpg$/jpeg/; push @imgs, { Type => $type, ID => $name, Path => $path, Filename => $fullname, Disposition => 'attachment', }; } use Data::Dumper; print Dumper \@imgs; __DATA__ /images/logo.gif /images/footer.gif /images/whatever.gif