First of all, don't worry about asking questions that you think are stupid.

Your code has a number of problems:

Anyway, none of this really helps you solve your problem. I would put the directory listings in a separate directory. Take a look at this code (untested):

use strict; use warnings; use File::Find; my $listings_dir = 'c:/listings'; find(\&callback, 'c:/tmp'); sub callback { my $file = $_; # Check to see if $file is a directory if (-d $file) { # Get a list of all the files in the directory (inefficient) # (If you only want the filenames rather than paths as well, # investigate using File::Basename. If you want just the files # in a directory, and directories within the directory, # consider putting grep { -f $_ } before the glob. my (@files) = glob($File::Find::dir . "/$_/*"); # Save this list to a file open LISTING, ">$listings_dir/list$_.txt"; print LISTING join ("\n", @files); close LISTING; } }
Good luck with learning Perl. I strongly recommend learning Perl properly--get yourself a copy of "Learning Perl". Your investment in learning Perl will pay back very quickly.

In reply to Re: Some problems with my code - Help... by SuperCruncher
in thread Some problems with my code - Help... by star7

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.