in reply to Stripping a pattern from a variable

Save the unaltered version in another variable, then munge it. End up with both versions at the end. The regex you use in the substitution depends on the real situation, but everything else should be basically the same.

#!/usr/bin/perl while( <DATA> ) { chomp; my $munged = $_; $munged =~ s/-(?:spam|ham)(?=@)//; printf "%-30s --> %-30s\n", $_, $munged; } __END__ joe@example.com joe-ham@example.com joe-spam@example.com joespam@example.com wortham@example.com
--
brian d foy <bdfoy@cpan.org>

Replies are listed 'Best First'.
Re^2: Stripping a pattern from a variable
by xman2000 (Initiate) on Mar 24, 2005 at 15:56 UTC
    I am all set, thank you.
A reply falls below the community's threshold of quality. You may see it by logging in.