# the substitution is none in effect, it just digs around $page2 =~ s|(.*)|${my_count(\$1)}|gi; my matches = (); sub my_count { my $occurance = shift; push @matches, ${$occurance} ; return $occurance; } # see what we've got foreach (@matches) { print '
  • '.$_.'
  • '."\n"; # just to format the output :-) }