s/(?:\S+\s+){6}\K(.+)/($x=$1)=~tr,(),,d;$x/e
This removes the dependence on Perl version 5.14 for the /r modifier for the tr/// operator, but does not satisfy the latest approximation to the real spec as given here. (Don'tcha just love receiving specs via drip-feed?) The problem is easily fixed with a (\S+) vice (.+) capture (still requires Perl version 5.10+):
That still leaves a dependence on version 5.10 for the \K regex operator, again easily fixed with another capture:c:\@Work\Perl\monks>perl -wMstrict -le "use 5.010; ;; print 'perl version: ', $]; ;; my $rec = 'Jun 12 10 mail (sender@sender.com) - (recip1@domain.com),(recip2@d +omain.com) -1.889 25623, queued_as: B67837C0052 Subject goes here Sen +der(sender@sender.com )'; print qq{'$rec'}; ;; $rec =~ s/(?:\S+\s+){6}\K(\S+)/(my $x=$1)=~tr,(),,d;$x/e; print qq{'$rec'}; " perl version: 5.010001 'Jun 12 10 mail (sender@sender.com) - (recip1@domain.com),(recip2@doma +in.com) -1.889 25623, queued_as: B67837C0052 Subject goes here Sender +(sender@sender.com)' 'Jun 12 10 mail (sender@sender.com) - recip1@domain.com,recip2@domain. +com -1.889 25623, queued_as: B67837C0052 Subject goes here Sender(sen +der@sender.com)'
c:\@Work\Perl\monks>perl -wMstrict -le "print 'perl version: ', $]; ;; my $rec = 'Jun 12 10 mail (sender@sender.com) - (recip1@domain.com),(recip2@d +omain.com) -1.889 25623, queued_as: B67837C0052 Subject goes here Sen +der(sender@sender.com)'; print qq{'$rec'}; ;; $rec =~ s/((?:\S+\s+){6})(\S+)/(my $x=$2)=~tr,(),,d;$1.$x/e; print qq{'$rec'}; " perl version: 5.008009 'Jun 12 10 mail (sender@sender.com) - (recip1@domain.com),(recip2@doma +in.com) -1.889 25623, queued_as: B67837C0052 Subject goes here Sender +(sender@sender.com)' 'Jun 12 10 mail (sender@sender.com) - recip1@domain.com,recip2@domain. +com -1.889 25623, queued_as: B67837C0052 Subject goes here Sender(sen +der@sender.com)'
Give a man a fish: <%-{-{-{-<
In reply to Re^2: How can I replace the pattern in the 6 th field?
by AnomalousMonk
in thread How can I replace the pattern in the 6 th field?
by theravadamonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |