while (my $row = $sth->fetchrow_hashref()) { for my $imgfile (map $row->{"image_$_"}, 1..4) { unlink "../../pics/$imgfile"; } }