Hi harangzsolt33,

The problem you're experiencing does sound strange to me, especially with the behavior you describe here, but it's been a while since I worked with Perl on the command line in Windows - the explanations by the AM (here) seem plausible if you're trying to print lots of binary data.

I just wanted to point out that Perl has an operator that tries to tell "text" from "binary" files based on a heuristic: -T (the heuristic is described in the documentation).

Also, while walking a directory tree yourself is certainly a useful exercise, there are modules to help you, here's one example with Path::Class:

use warnings; use strict; use Path::Class qw/file dir/; my $PATH = dir('.'); $PATH->recurse( callback => sub { my $file = shift; return if $file->is_dir || -B $file; my $fh = $file->open('<:raw') or return; read $fh, my $content, 2000 or return; close $fh; print $content; } );

Just a small note, in your current code you have a few variables that could have better scoping. $CONTENT could be defined right before its use in read, then you don't have to clear it every time. And the $SUB you define at the beginning of explore is actually never used because it is shadowed by the second $SUB in the while loop.

Hope this helps,
-- Hauke D


In reply to Re: print all files is soo slow! Why? by haukex
in thread print all files is soo slow! Why? by harangzsolt33

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.