#!/usr/bin/perl -w use File::Copy; use 5.010; # For autodie and regex \K use Time::Piece; use Time::Seconds qw/ ONE_MINUTE /; use constant DATE_FORMAT => '%Y%m%d%H%M%S'; my $source_file = "KOH_1026.udr"; my $lines; my $tp; for my $i (1 .. 3) { copy($source_file, sprintf("KOH_1026%02d.udr", $i)) or die "Copy failed: $!"; open my $input_file, '<', $source_file; my @lines = <$input_file>; close $input_file; foreach (@lines) { $n++; $lines[0] =~ s~/(4947000219)/$1+$n/~e; $lines[1] =~ s{:20140924105028(\d+)}{ $tp = Time::Piece->strptime($1, DATE_FORMAT); ($tp + ONE_MINUTE * 2 * $n)->strftime(DATE_FORMAT); }e; open my $output_file, '>',$source_file; print $output_file @lines; close $output_file; } }