my $text; { open(local *INPUT, '<', "data") or die "Unable to open input file: $!\n"; local $/; # Read whole file at once. $text = ; } $text =~ s/(\d+)$/ $1 >= 4_000_000_000 ? $1 : "$1 <---- LOW!" ; /emg; { open(local *OUTPUT, '>', "data") or die "Unable to open output file: $!\n"; print OUTPUT ($text; }