Hi, I implemented this code to separate a bunch of files into different categories(%dig and so on). When thought to speed up a little the iteration eliminating form both @img and @vid the items already processed by the last two grep statements, I noted instead that after few iterations the $img variable were returning, at the beginning of the loop, the correct file name but anticipated with the following symbols "?^:". I thought that the loop would affected in some way by this "dynamical" sizing of its array ... what you think about this results ? ... or maybe is my dev ambient "Perl Builder 2.0" for win. ..can you recommend me a different one, more optimized for x64 ? free of charge for instance ? Thanks Simon

....... $footprint_im = 'jpg gif png tiff tif'; $footprint_iv = '^vid.+ 3gp mp4 avi'; $footprint_lnk = 'lnk'; $footprint_im .= ' '.uc $footprint_im; $footprint_im =~ s/ /\$\|/g; $footprint_iv .= ' '.uc $footprint_iv; $footprint_iv =~ s/ /\$\|/g; $footprint_lnk .= ' '.uc $footprint_lnk; $footprint_lnk =~ s/ /\$\|/g; for($i = 1 ; $i <= @ff ;$i++){ next if grep{/$i/}@input; clean($ff[$i-1]); } sub clean{ my $dir = shift; $dir =~ s/\\/\\\\/g; $dir .='\\\\'; opendir F, $dir; @imgg = readdir F; @lnk = grep{/$footprint_lnk/} @imgg; @img = grep{/$footprint_im/} @imgg; # @img = grep{/jpg$|JPG$|gif$|GIF$|png$|tiff$|TIFF$/} @imgg; @vid = grep{/$footprint_iv/} @imgg; closedir F; undef @imgg foreach $img(@img,@vid){ # $img = (@img,@vid)[$i]; # $rr = $img; # $rr =~ s/\(\?\^\:(.+)\)/\1/; # $rr =$1; open my $fh, '<', $dir.$img; my $md5 = Digest::MD5->new->addfile($fh)->hexdigest; close $fh; if ((!$dig{$md5}) and (grep {/$img/} @img)){ $dig{$md5} = $dir.$img ; $dig = values %dig; print R "$md5\t$dir.$img\n"; }elsif ((!$dig_v{$md5}) and (grep {/$img/} @vid)){ $dig_v{$md5} = $dir.$img ; $dig_v = values %dig_v; print R "$md5\t$dir$img\n"; }else{ $del{$md5} = $dir.$img ; } # splice(@img,$i,1) if $rr =~ /$footprint_im/;; @img = grep {!/$rr/} @img; @vid = grep {!/$rr/} @vid; } ...... }

In reply to Strange result on array by solocazzimiei

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.