#!C:\Perl64\bin\perl -w use strict; # Iteration 1, open myfile.txt open(FILE, "; close(FILE); #This section uses an array and scans each line and does a #sequential search and replace for the following strings: #1. Finds any instance of || and changes it to | | #2. Finds any instance of | || and changes it to | | | #3. Finds any instance of || | and changes it to | | | #4. Finds any instance of | | at the end of a line and #changes it to || my @newlines; foreach(@lines) { $_ =~ s/\|\|/\| \|/g; $_ =~ s/\| \|\|/\| \|/g; $_ =~ s/\|\| \|/\| \|/g; $_ =~ s/\| \|$/\|\|/g; push(@newlines,$_); } #Push changes to MyFileNew.dat open(FILE, ">/temp/PERL-Samples/MyFileNew.dat") || die "File not found"; print FILE @newlines; close(FILE);