blackadder has asked for the wisdom of the Perl Monks concerning the following question:
That calls on those two scripts;use strict; use threads; use threads::shared; use Win32::FileSecurity; my @source: shared; my @childs; my $child; my @list; $list[0]=qw(c:\\winnt); $list[0]=qw(\\\\serverA\\g$\\Eng_Support\\Data_Removal); $list[1]=qw(\\\\serverA\\f$\\homedirs\\users0\\adb0290); for (@list) { push @childs, threads->create("size_up","$_");#line 16 #push @childs, threads->create("file_up","$_");#line 17 } foreach $child (@childs) { $child->join(); } printf "%s ", join ("\n", @source); sub size_up { my ($path) = @_; my $resp; $resp = `size_test.pl $path`; push (@source, "$path\t" . $resp); } sub file_up { my ($path) = @_; my $resp; $resp = `file_test.pl $path`; push (@source, "$path\t" . $resp); }
And#size_test.pl use strict; use Win32::OLE qw[in with]; my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $size = 0; my $d = $fs->GetFolder("$ARGV[0]"); eval { $size = $d->size( ); my $size_gb = ($size/1024/1024); print "Size: ".$size_gb."Mb ($size byte)"; };
The main script will not work unless either lines 16 or 17 are commented out.#file_test.pl use Win32::OLE qw[in with]; my $fs = Win32::OLE->CreateObject('Scripting.FileSystemObject'); my $fCount =0; my $sCount =0; my @folders = $fs->GetFolder("$ARGV[0]" ); eval { while( @folders ) { my $folder = pop @folders; $fCount += $folder->Files->Count; $sCount += $folder->SubFolders->Count; for my $subFolder ( in $folder->SubFolders ) { $fCount += $subFolder->Files->Count; push @folders, $_ for in $subFolder->SubFolders ; $sCount += $subFolder->SubFolders->Count; } } print "Files: $fCount, folders: $sCount"; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Threads problem.
by BrowserUk (Patriarch) on Oct 03, 2003 at 23:05 UTC | |
by blackadder (Hermit) on Oct 06, 2003 at 20:08 UTC | |
by BrowserUk (Patriarch) on Oct 07, 2003 at 01:03 UTC | |
by blackadder (Hermit) on Oct 07, 2003 at 19:47 UTC | |
by BrowserUk (Patriarch) on Oct 07, 2003 at 19:56 UTC | |
by BrowserUk (Patriarch) on Oct 07, 2003 at 23:29 UTC | |
| |
by blackadder (Hermit) on Oct 13, 2003 at 20:26 UTC |