in reply to fork and reap

OK, hard to say whats going wrong when you don't include forkit. Anyway, lets see if we can find some improvements. The only thing I can really make out is smallest. No need to use ls, as it might confuse your forkIt(if you use wait). Try this instead:
smallest{ my ($dir,$arr_ref)=@_; my %sc; #Cache of file sizes; return +(sort {$sc{$a}||=-s $a; $sc{$b}||=-s $b; $sc{$a} <=> $sc{$b} } map { "$dir/$_" } @$arr_ref)[0]; }
That should be efficent enough.

As for the rest, I don't understand what you try to do. You have one main loop. The first thing you do, is to shift a file off  @dbFilePaths. That means it will only go through that loop once for all those filepaths. Inside the loop is one big if/elsif block. So, for each of those FilePath's, one of those blocks will be executed, and finally you fork of, presumably to execute the command you set in the if/elsif block

Furthemore, since you never set @copiedFiles or @verifiedFiles, 2 of those blocks will never get executed. I think you should try to post a version that you feel is somewhat correct, or failing that, put in some comments on what you think is going on in the code

GoldClaw

Replies are listed 'Best First'.
Re: Re: fork and reap
by Anonymous Monk on Mar 15, 2001 at 05:03 UTC
    Dunno why forkIt fell off the bottom. You're exactly right about the flow of the program. ForkIt is supposed to send a child off to run the command.

    Thanx for your sorting sub. I'll plug that in. It didn't even occur to me that the ls call would show up as a forked thing and throw off the rest of the tests. Many thanx for pointing that out.

    I've been thinking about moving to a system that doesn't use the copied, zipped, and verified lists, since I have a status hash.

    Gonna go implement your excellent suggestions and some of the other ideas I've come up with.

    Thanx.