for($i=0; $i<$glob; $i++){ $_ = @text[$i]; if(/href="?([^">]*)\?eid=/is){ $counter = 1 - $counter; print $1 if $counter; } }