I presume there are some typos here with the superfluous colons:

my($hf) = File::Util->;new(); my(@HighFolders) = $hf->;list_dir($Highpath,'--dirs-only');

If I follow you properly, you might want to make one single datastructure here -- each element of the "Highfolders" array would be an array reference. The first element of that array (0) would be the MMYY name, the second element (1) would be another array reference to an array containing the subfolders. I think this would eliminate the need for unique names (unless there is some further reason for that). Might look something like:

#!/usr/bin/perl -w use strict; use File::Util; my $hf = File::Util->new(); my $path = '/'; my @Folders; foreach ($hf->list_dir($path,'--dirs-only')) { my @tmp = $_; push @Folders, \@tmp; # the outer array ref } foreach (@Folders) { my $lf = File::Util->new(); my @tmp = $lf->list_dir($path.$_->[0],'--dirs-only'); $_->[1] = \@tmp; # inner array ref } # verify: foreach (@Folders) { print $_->[0]."\n"; foreach my $sub (@{$_->[1]}) { print "\t$sub\n"; } }

I haven't used File::Util before so I inferred from your code, but I did test this -- I hope that's kinda what you are looking for. It's nice to comment on datastructures like this in the code, eg:

my @Folders; # array of array refs, each sub-array = # 0: directory name # 1: array of subdirectories

In reply to Re: Deleting folders based on name. by halfcountplus
in thread Deleting folders based on name. by fazedandconfused

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.