There is nothing wrong with the code. I did a UNIT TEST just to make sure. Try running the following and you will notice that it exits out and does not print when the
if($_ eq $img_name)
statement is reached.
@array = (0, 1, 2, 3, 4, 5);
foreach(@array){
if($_ eq 3){
last;
}
print "$_\n";
}
#this will output
#0
#1
#2
Try checking to make sure $img_name is what you think it is, or it may be that the defined $img_name is not contained within the file and therefore no match will be made? |