final result would be

file1:- 12 4947000219 20140924105028

file2:- 12 4947000220 20140924105228

file3:- 12 4947000221 20140924105428

Done the changes in code,no error but not getting desire result

#!/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 faile +d: $!"; 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; } }

Error Message

String found where operator expected at ./prog.pl line 33, near "$lines1 =~ 's{:20140924105028(\d+)}'" (Missing operator before 's{:20140924105028(\d+)}'?) syntax error at ./prog.pl line 33, near "$lines1 =~ 's{:20140924105028(\d+)}'" Can't use global $1 in "my" at ./UDR_Tool.pl line 34, near "($1" syntax error at ./prog.pl line 41, near "}" Bareword "e" not allowed while "strict subs" in use at ./prog.pl line 36.

Monks need your help to resolve the issue


In reply to Dera Monks, Have create multiple file from one file now I want to match a pattern in each file at the same time do the replacement with adding one to the match pattern. by hemantjsr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.