Hi!

I'll just answer that question, since merlyn has stated often enough that he doesn't have the time to answer all the "easy" questions.

Lines 2 and 3 put those filenames into the @ARGV array, which has the same effect as putting those filenames in the commandline (@ARGV contains all words in the commandline after the name of the called script.) The operator <> reads from all the filenames on the commandline, or from STDIN if there are no filenames on the commandline. So line 2 and 3 actually do read those files into those arrays without needing an open statement. Beautiful!

In line 4, the array @daily is used in a scaler context, since it is compared with a scalar (3). In a scalar context an array returns its length, in this case the number of lines in the file. So you don't need that # operator, although you could use it.

I hope I got that all right, I'm pretty new to perl myself. My compliments to merlyn, that is very short yet very readable code. Perl is beautiful!

Christian


In reply to RE: Reading and writing to files: Debrief Question by cmburns
in thread Reading and writing to files by damian

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.