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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |