What is the most efficient way to list a directory?

Viewed 219

So my title might not be the most descriptive but essentially I am doing this in one class:

  • Launching a perl script that creates a series of files
  • In another function within the same class, I would like to provision certain files that I have created from my first script into another script

    //process 1
    launchOnCommandLine("perl --arg1 -arg2");
    

What the above script does, is that it produces a bunch of files in the current working directory. In a second script what I want to be able to do is retrieve all the output files of extension (.example), retrieve their paths, concatenate them in a comma-seperated list, and feed it into a second script.

    //process 2
    launchSecondScript("perl --list-of-comma-seperated-file paths

What is the most efficient way to retrieve that comma-seperated string of file paths and provision it to a second function. I also know the directory where the files will be outputted so that is not a problem.

2 Answers
Related