#!C:/Perl/bin/perl.exe use strict; use warnings; my $ip_1 =~ m/(\d)-/g; $ip_1 = int($ip_1); my $ip_2 = $ip_1 - 1; my $input_file = 'CrystalReportViewer1.csv'; my $output_file = 'CrystalReportViewer2.csv'; open(my $output_fh, '>', $output_file) or die "Failed to open $output_file - $!"; open(my $input_fh, '<', $input_file) or die "Failed to open $input_file: $!"; while ( <$input_fh> ) { s/$ip_1/$ip_2/; print {$output_fh} $_; } close $output_fh;