Please do spend some minutes reading one or two basic Perl tutorials, just because at the least it will help you formulate questions better and also allow you to make an attempt in Perl at what you want to do, and then post what you have tried, here. You'll get better help, faster, that way :)

The above post by Roboticus gives some great info on reading through the lines in a file. You'll also have to consider how to open the file for reading, how to handle an error if that fails, etc.

One of Perl's strengths is the vast public library of modules that already do most of what you need to do. There are lots of ways to open and read from a file, but like everything in Perl, you quickly reach the point at which it is more efficient to use a pre-existing module.

You might search on meta::cpan for "file", or "path", or "file open", or "file read", or something like that, and see what you get.

It is nice to be able to do in your code only this, as one example, to get to where your pseudo-code example begins:

#!/usr/bin/env perl use strict; use warnings; use File::Slurp::Tiny 'read_lines'; my $file = '/path/to/file'; for ( read_lines($file) ) { # do something }

In reply to Re: Searching for Patterns in CSV by 1nickt
in thread Searching for Patterns in CSV by Fischer

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.