I have this main script below
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); }
That calls on those two scripts;
#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)"; };
And
#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"; };
The main script will not work unless either lines 16 or 17 are commented out.

Does anyone knows why is this? And how can I get both lines working together (i.e. without having to comment either lines 16 or 17)?

Thanks,

In reply to Threads problem. by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.