in reply to Find Credit Card Numbers and Mask only 6 digits in a logfile

I don't understand this: "The problem is to identify the number in the file because I cannot open the file because sometimes files are too large.". Maybe you are trying to read the whole file into memory at once? Open the file and read it line by line. Use a regex to modify the number, perhaps something as simple as this:
use strict; use warnings; my $n = 'asdfklj fuyy23 1234567890123456 78vc'; $n =~ s/(\d{6,6})(\d{6,6})(\d{4,4})/$1******$3/; print "$1 $2 $3\n"; print $n; __END__ 123456 789012 3456 asdfklj fuyy23 123456******3456 78vc