Help for this page
$$file =~ s/<%[ ]*link_name[ ]*([^ ]*)[ ]*%>(?{push(@link_names,$1);})/<% link_n +ame $1%>/g; ... ){ push @link_names,$1 }
while($$file =~ m{( <% \s* link_name \s* (\S*) \s* %> )}xg ... # you know the positions of your links and their # length, so use substr(!) here }