valax has asked for the wisdom of the Perl Monks concerning the following question:

Okay, lately I have been addicted to perl and I've learned a lot, but I can't figure out how to add something to something after such and such. I made a simple ftp scanner that scans through and outputs all files and folders recursively, well, up to a certain point. Right now I use this my $global = 'www/*'; which will scan all folders and output their contents after the www folder like so

www/folder1:

files

www/folder2:

files


And so on.

If I use my $global  = 'www/*/*'; It will output:

www/folder1/folderinfolder1:

files

www/folder2/folderinfolder2:

files

And so on.

Now, I know this isn't exactly the best way about doing it, but I have spent ages trying to find how to simply print all content from the ftp recursively, and during that search I found many things and examples which didn't actually work, but then I finally managed to figure it out (sort of) and get to this point. So, my question is, how could I add /* to the initial www/* so it becomes www/*/* after it has finished scanning www/*?

Also sorry but I can't find anywhere that tells me how to format posts.
  • Comment on Adding another wildcard directory after scan.

Replies are listed 'Best First'.
Re: Adding another wildcard directory after scan.
by toolic (Bishop) on Jul 04, 2010 at 17:33 UTC
    Welcome to the Monastery.

    It would be easier to read your posting if you update it using code tags around your code. Refer to Writeup Formatting Tips.

    If you want to recursively list contents of directories, you could use File::Find (which is a Core module part of the Perl installation) or File::Find::Rule (which is a CPAN module) which many find easier to use.

    Or a glob solution:

    my @global = glob 'www/* www/*/*';
      First of all, thank you for linking me to the formatting tips.
      
      Secondly, thank you for answering my question.
      
      I wasn't aware I could actually do 'www/* www/*/*'; and so on. 
      
      
      That works perfectly, thanks again.
      
      File::Find isn't going to help if the OP is listing a remote directory over ftp. Though a little code from the OP would help to see what he's really trying to do.