Dear Wink,
Thank you very much to show me the efficient way of doing things. I am quite new at programming and I'm learning Perl on my own!! (with the Monks).
Any way, I don't know how to clarirfy the hurtle. One thing I know is that if I have "user1, user2, user3 and then user1 again, the method calculates the right size for user1 then user2 and user3 and then gives me a long error message at the DOS prompt and eventhough the program goes on and displays what was calculated (that is done with the make_table method that I am not showing here), the program is not functional anymore and has to be closed. The duplicates are only in the user names. For example, I ask my program to go get the size for: C:\documents and settings\desktop\testfolder\ and then in a for loop I append the name of the folder under testfolder.
I though of dealing with the duplicates before it even tries to calculate anything by sorting the array and checking if I have duplicates before I launch the method, but I have another issue with that. The issue is really embarrassing because Perl execute the if statement and the else statement also!
Here is the all method:
sub create_file_for_batch{ if($dest ne "" && $source ne "" && $logpath ne "" && length($sourc +etext)!=1){ $sourcetext=$sourcetextentry->get('1.0','end'); $original_dest = $dest; $dest =~s/\//\\/g; $original_source = $source; $source =~s/\//\\/g; $switches=""; save_switches(); print LOG ("The destination path was: $dest\n The source path was: $source\n The path for the log file is: $logpath\n The users are: $sourcetext\n"); @arraybatch = split /,|\n/, $sourcetext;#splits what is in the + variable $len = @arraybatch; for($i=1; $i<$len; $i=$i+2){ $arraybatch[$i] =~s/\G //g;#gets rid of the space in front $arraybatch[$i] =~s/ /_/g;#put _ in place of the space bet +ween the name push @arrayfilename, $arraybatch[$i]; }#for for($i=0; $i<$len; $i=$i+2){ push @arraydirectory, $arraybatch[$i]; }#for @sortedarraydirectory = @arraydirectory;#makes a copy of the a +rraydirectory so I can sort @sortedarraydirectory= sort @sortedarraydirectory;#sort the co +pied array $len = @sortedarraydirectory; for ($i=0; $i<$len; $i++){ if ($sortedarraydirectory[$i] ne $sortedarraydirectory[$i+ +1]){ make_table(); $notebook->pageconfigure('page1', -state=>'normal'); $notebook->pageconfigure('page2', -state=>'normal'); }else{ $dialog = $page3-> Dialog( -title => 'Alert', -text => "$sortedarraydirectory[$i] is a duplicate. Pl +ease correct the batch file.", -buttons => [ qw(OK) ]) ->Show(); }#else }#for }else{ $dialog = $page3-> Dialog( -title => 'Alert', -text => "Please enter paths for destination, sources and log +file and fill out the text area for batching", -buttons => [ qw(OK) ]) ->Show(); }#else }#create_file_for_batch
The outside if else statement works just fine it is just the if and else inside that does not act properly.
I would be very appreciative if you could point out what I am doing wrong, as I am about ready to give up on checking for duplicate all together!
Thanks,
Claire

In reply to Re^4: Duplicates in Win32::DirSize by Real Perl
in thread Duplicates in Win32::DirSize by Real Perl

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.