Hello hemantjsr,

Like Laurent_R, I don’t understand what you are trying to do. However, in the code posted I do notice a major problem in the use of variables. First, in the lines:

foreach my $line (@lines) { $line = $_;

$_ is undefined, so you are immediately deleting the contents of $line and replacing them with undef. (And the line would accomplish nothing, anyway, even if $_ did contain the next element of @lines, as that element has already been stored in $line via the foreach statement.)

Second, in the lines:

$line[0] =~ s~/4947000219/\K(4947000210+)~$1+$n~e; $line[1] =~ s{:20140924105028\K(\d+)}{

you are accessing the first and second elements of the array @line. But as this array has never been declared, the substitutions have nothing to work on. Please note that the array @line is an entirely different variable from the scalar $line. (I notice that you do declare a variable my $lines, but that variable is never used.) If you begin your script with:

use strict;

this will provide some (but not all) of the help you need to identify errors of this kind. See also Perl variable types and perldata.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: Dear Monks, Have created multiple files from one file ... by Athanasius
in thread 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.