Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: A very odd happening (at least. . . to me)

by maverick (Curate)
on Jun 24, 2002 at 16:09 UTC ( #176843=note: print w/replies, xml ) Need Help??

in reply to A very odd happening (at least. . . to me)
in thread Processing large files many times over

From a quick glance at the code, one of the first questions that comes to mind is "how many files are in these directories?" I suspect that part of the source of your slowness is that you read both the entire list of files, and the entire contents of each file into memory. If you alter your reading structure like so:
open(DIR,"$base_dir\\$dir") or die "$dir failed to open: $!"; while (my $file = readdir(DIR)) { next unless $file =~ /\.txt$/; # etc, etc. open(IN,"$full_name") || die "can't open $!"; while (my $line = <IN>) { # processing } close(IN); } closedir(DIR);
you won't have the overhead of all the memory allocation. In your second example there's a system call to a secondary perl script. That's going to be time consuming too. Consider making the second perl program a subroutine...that will avoid a fork, exec, and compile for every file you have.


OmG! They killed tilly! You *bleep*!!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://176843]
[LanX]: na, they go easy on germans since they discovered the German TV market
[Your Mother]: Zeitgeist. :P
[LanX]: Talking about Peacemakers, I still need to watch 2 seasons of Farscape ...
[Your Mother]: I liked that show a lot.
[Your Mother]: Packed with minority women.
[LanX]: pitty they burned the actors in Stargate
LanX ... uhm ... wait...
[Eily]: LanX I don't see the woman
[LanX]: at the right, tanned , gib boobs, chains
[LanX]: big

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2018-03-19 14:41 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.