#!/usr/local/bin/perl -w use strict; my $pattern = quotemeta( "|" ) . '?[ *|\.*]' . quotemeta( "|" ); while() { print; chomp; s/\cM//g; s/$pattern/\|\|/g; print "$_\n"; } __DATA__ 6|11-XXX-03|999999999|.| |0000|.|.|.|.|.|.| | |.| | | | |.|.| |.|0|N