Hi Monks,

I have one file which contains a header and rest details. Now I have to read the file header. There are around 30 fields in the header and each separated by "|".

There will be a fixed pattern in the header "LASTUPDATE" , I need to find out the position of this in the header.

Now after taking the position of this fixed pattern , I need to read the subsequent second line from the file and take out the date field which will be in the same position.

My question is that

in file reading if I am reading the file from the very first line can I refer the first line as line[0] and then the second line as line1

I will read the first line and assign it to an array and then I will match the pattern and take the position of that element.

Then I will read the second line as line1 and then again assign it to a new array and then read the position as got from first line.

Kindly advice


In reply to file handling by ashish_sun123
in thread Please tell by ashish_sun123

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.