The problem is not a discrepancy between the size reported by WinXP (via say dir or explorer) and that returned by -s, they will be exactly the same.

The problem is the length of the file as loaded into you code if you do not use binmode.

Without binmode, linefeeds within the file on disk, are translated into carriage return/linefeed pairs (and reverse done on output).

Hence:

open I1, '<:raw', 'zz.pl';; $d1 = do{ local $/; <I1> };; print length $d1;; 6712 open I2, '<', 'zz.pl';; $d2 = do{ local $/; <I2> };; print length $d2;; 6571 !wc -l zz.pl;; 141 zz.pl print unpack 'H*', substr $d1, 0, 100;; 23 21 20 70 65 72 6c 20 2d 73 6c 77 0d 0a 75 73 ... print unpack 'H*', substr $d2, 0, 100;; 23 21 20 70 65 72 6c 20 2d 73 6c 77 0a 75 73 ...

In your example, myfile.pl has 2179 lines.

The solution is to use binmode (or '<:raw' & '>:raw' etc.).


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Filesize (-s) is consistenly reporting too small of size in Win32 by BrowserUk
in thread Filesize (-s) is consistenly reporting too small of size in Win32 by wilsond

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.