while(){ my $orig = $_; if ( s/foo\@there\.com/bar\@here\.com/ ) { print "< $orig> $_\n"; } } __DATA__ foo@there.com john.foo@there.com foo@there.com.au Mr Foo