$tree = HTML::TreeBuilder->new_from_content($html);
foreach my $img ($tree->look_down('_tag', 'img')) {
my $alatt = $img->attr('alt')
if (!$alatt) {
$imgsrcattribute = $img->attr('src');
use File::Basename;
my @suffixlist = qw(gif, jpg, jpeg, png, bmp, php, ico, GIF, JPG, JPEG, PNG, BMP, PHP, ICO);
my $imgfilenopathnoext = fileparse($imgsrcattribute,@suffixlist);
my $newalttag = HTML::Element->new('img', alt=>"");
$newalttag->attr('alt', "$imgfilenopathnoext");
$html->push_content($imgfilenopathnoext);
$imgfilenopathnoext = $imgfilenopathnoext->delete;
print "Alt tag not found for $imgsrcattribute \nInserted src file name $imgfilenopathnoext for alt attribute";
}
}