sub processdir(){
my $pm = new Parallel::ForkManager(5);
$pm->run_on_finish( sub { my ($pid, $exit_code, $ident) = @_; $tmp
+Files[$ident] = undef; } );
foreach my $i (0..$#Files) {
# Forks and returns the pid for the child:
my $pid = $pm->start($i) and next;
$SIG{INT} = 'DEFAULT';
my $filename = $Files[$i]->filename();
my $file = IO::File->new("<$filename") or die "Can't open $filen
+ame\n";
while((my $line) = $file->getline()) {
last unless defined($line);
chomp $line;
my ($dir, $file) = split(/\t/, $line);
$processor->($dir, $file, $config, $log);
}
$pm->finish; # Terminates the child process
}
$pm->wait_all_children;
return;
}
processdir($input_dir,$logfile,\&clean_value);
sub clean_value(){
$logfile->print("-- Reading '$input_file' file\n");
}
Here all the process executes,writes together and input file name overlaps in the file name
How to avoid overlapping of file names into the $logfile.
In which portion should I use locks or how to avoid averlapping of filename
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|