open; split and on-and-on....

or, if your learning style is compatible with examples...check Super Search for threads here dealing with the issues you face, and see also http://www.perlmonks.com/index.pl?node=Tutorials#Input-and-the IO tut in our Tutorials section.

But a couple points about your question:

  1. Is the data sample you posted an example of a single line (record) in data.txt or are each of the label:value pairs on a separate line or something else entirely? (Implicit hint made explicit: your questions will generally get quicker and better help if your problem statement is precise.)
  2. Your question suggests that you might hope to learn Perl by studying the syntax of some functions. That's probably sub-optimal. The "chapters" element is likely a better route, and which text to recommend depends (to some extent) on the extent your prior experience as a programmer.
    But without that info, it's hard to do better than recommending Learning Perl, 6th ed. But beware: the first several hits if you simply Google the title appear to be UNauthorized ... ie, ripoffs of the authors and O'Reilly.

Edits for fact, spelling and references. Aaagh!


In reply to Re: How can I enter the data of different variables from a text file into a perl program? by ww
in thread How can I enter the data of different variables from a text file into a perl program? by supriyoch_2008

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.