Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

If you're new to Perl, which programming language are you proficient in? What resource are you using to aid your learning of Perl? And what have you tried so far?

If you're new to Perl, but competent in some other language, sometimes it helps for us to be aware of that so that we know how to answer in a way that will make the most sense in consideration of your background. If your background is that you don't know the first thing about programming, that would be helpful for us to know as well. Everyone starts somewhere, and there's no shame in that. We're also fairly familiar with many of the learning resources commonly available on the subject. So if we know where you're coming from in that regard as well, we may be able to sort of fill in the gaps or refer you to portions of that resource that might provide additional information. But like I said, everyone starts somewhere, and we all learned Perl somewhere along the way. There's nothing wrong with that.

Not everyone duplicate-posts their original question, and then one-ups that by duplicate-posting their followups as well. Some do though, so you're not alone. But in the absence of additional background information, that sort of thing will probably skew our assessment as to what level of computer literacy our answers should target.

One easy way to read from a flat file is to use the open function (described in better detail perlintro, open, and perlopentut). Next one would use the <> (diamond operator), as described in perlintro and perlop. This combined with a while(){} loop (perlintro and perlsyn) is almost all that's needed for the common idiom:

open my $file_handle, '<', 'filename.txt' or die $!; while( <$file_handle> ) { chomp; # do something with the line held in $_ } close $file_handle;

my, die, and chomp may also be helpful to your learning process.


In reply to Re^3: reading flat file by davido
in thread reading flat file by raj000

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [Cosmic37]: hey erix are you there? earlier you said that one should check whether neural networks actually work... did you have a bad experience with neuralnetworks?

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (2)
    As of 2018-02-20 19:50 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (274 votes). Check out past polls.