Thanks Choroba for your reply, I agree it should have worked, which is strange. However, I found a way to get it work, here is solution below. I think the problem was the subroutine call from the previous code, which I removed and modified the foreach loop in complete code as seen below.

#removed from current code copySelected(\@branchesSelected);
#complete solution below #!/web/soft/iw-home/TeamSite/iw-perl/bin/iwperl use strict; # require variables to be declared use diagnostics; # expand warnings (-w) expanation use File::Find; my @branchesSelected = qw(test_branch); my %options = (preprocess =>\&new_dir, wanted=>\&wanted); find ( \%options, @root); ###################################################################### +### # process files per directory ###################################################################### +### sub new_dir { my @files = @_; # the readdir() output # contains both (files and directories) # find html files under pages directory if ($File::Find::dir =~ m|pages|) { # sort files @files = sort(@files); # process files and directories foreach my $name (@files) { next if ($name !~ m|workshop|); # scan files if (-e $name) { # skipped if not html file next if ($name !~ m|\.html$|); push (@copyFiles, "$File::Find::dir/$name"); } elsif (-d $name){ mi0::LogManager::info("Directory found $name, cannot c +opy folders"); } else{ mi0::LogManager::info("No Files found"); } copySelected(\@copyFiles); mi0::LogManager::info(""); } } return @files; #return the list to continue processing } # End of sub new_dir { ###################################################################### +### # needed for syntax, extra's for getting size etc. if needed ###################################################################### +### sub wanted { # not used here, but dummy sub is needed for syntax # this routine is called for each file/directory # if we wanted to do something special for each one # maybe get a size or whatever... # the full path name of this file would be in $File::Find::name } # End of sub wanted { sub copySelected ($) { my $copy_selected = $_[0]; my @selectedBranches = qw(); my @selectedFiles = qw(); foreach my $selected (@$copy_selected) { next if $duplicates { $selected }++; if ($selected =~ m|\/|g) { mi0::LogManager::info("files selected: $selected"); push(@selectedFiles,$selected); } else { mi0::LogManager::info("branches selected: $selected"); push(@selectedBranches,$selected); } } #solution foreach my $branches (@branchesSelected) { mi0::LogManager::info("branches selected: $branches") if !$dup +licates { $branches }++; foreach my $files (@selectedFiles) { $files =~ s|$copyFromBranch|$branches|g; mi0::LogManager::info("files copied: $files"); } } }

In reply to Re^2: Not getting values from combined foreach loops by begood321
in thread Not getting values from combined foreach loops by begood321

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.