I am trying to do a replace of a specific set of characters in a file in Perl but it does not seem to work, here is my code.
my $file = shift;
open(FILE, "$file") or die "File not found";
while (<FILE>){
$data .=$_
}
$data =~ s/[^A-CEGHJ-PR-TW-Z]{1}[A-CEGHJ-NPR-TW-Z]{1}\s?[0-9]{2}\s?[0-9]{2}\s[0-9]{2}\s?[A-DEM]{0,1}$/XX012345X/g;
I know that my pattern matching works for finding the set of characters, I am not entirely sure the replace works. However, my main concern is the Perl code. The file remains untouched after I run it.
Sample File.
AB123456C Ab12345678 DG657465 GH123456FG