#!/usr/bin/perl use warnings; use strict; use File::Find; use File::Basename; use Parallel::ForkManager; my $masterDirect = '//server/secret/juice/2012/'; find(\&file_names, $masterDirect); my @files; sub file_names { if( -f && $File::Find::name=~/\.special$/) { push @files, $File::Find::name; } } my $maxProcs = 14; my $pm = new Parallel::ForkManager($maxProcs); foreach(@files){ my $pid = $pm->start and next; my @name = split /\//, $_; my $id = pop(@name); my @safeID = split / /, $id; my $perlOut = join "/", @name; my $safeDirect = $perlOut.$safeID[0]; #safe is hipaa compliant my $specialCommand = $_; $specialCommand =~ s/\//\\/g; # needs to be windows formatted. I tested it $specialCommand = "\"".$specialCommand."\""; my $specialTxtOut = join "\\", @name; $specialTxtOut ="\"".$specialTxtOut."\""; my $companyCommand = "apt-sauce-to-txt -o ".$specialTxtOut." ".$specialCommand; unless(exists($specialLog{$safeDirect})) { # log file test, not shown in this truncated script system($companyCommand); # SEND COMMAND TO THE TERMINAL } ##### # # BEGIN TXT PARSING # ##### my $specialTxtFile = $_.".txt"; if ( -e $specialTxtFile ) { open IN, $_.".txt" or die "CANNOT OPEN special.TXT FILE: INSTANCE 1\n"; while(my $line=){ ##### # # PARSING HAPPENS HERE, NOTHING FANCY HERE LADS # ##### } close(IN); # SEE! } unlink $_.".txt"; # I'VE USED $specialTxtFile too, same result $pm->finish; } $pm->wait_all_children;