while () { my @tokens = split /-+/, $_; foreach my $token (@tokens) { $token = do_html_balancing($token); do_something_else_with_token($token); } }