in reply to syntax error

You should check for mismatched {}'s I did some cut & paste action below, maybe it will help you see. I "think" you may have an extra } before your first else, and you may be missing one before your elsif. Just my best guess :-)
if ($page == "0"){ foreach $pic (@images){ if ($ttlcounter <= "24"){ if ($tmpcounter eq "3"){ }else{ } } }else{ } } elsif($page eq "1"){ { } foreach $pic (@images){ if ($ttlcounter =< "24"){ if ($tmpcounter == "3"){ }else{ } } }else{ }
LR