[ create a new paste ] login | about

Link: http://codepad.org/VSTuksBJ    [ raw code | output | fork ]

Perl, pasted on Jun 5:
1
2
3
4
5
6
7
8
9
10
11
$str = '5-29@foobar@invalid.com@ZZ88-6@550 5.1.1 <foobar@invalid.com>... User Unknow@GGH93';
#$str= '2012-05-29@joedoe@example.com@AB99-5@440 4.4.1 Some error occurred@XYZ35';

$str =~ s/(\<[^\>]+\>)/!!/; # replace an email address with !!
$email = $1; # store the email

@fields = split(/@/,$str); # split on @

s/!!/$email/ foreach (@fields); # find the old !! and replace with the email address

print STDERR map { "$_ \n" } @fields; # print fields to standard error


Output:
1
2
3
4
5
6
5-29 
foobar 
invalid.com 
ZZ88-6 
550 5.1.1 <foobar@invalid.com>... User Unknow 
GGH93 


Create a new paste based on this one


Comments: