#!/usr/bin/perl use strict; use warnings; my @test = ('a' .. 'z'); for my $chr ( @test ) { $chr =~ s/x/&foo/e; print $chr; } # for sub foo { print "\nfoo called\n"; return ''; } # foo