<p>I would like to execute <code>ls</code> in a Perl program as part of a CGI script. For this I used <code>exec(ls)</code>, but this does not return from the <code>exec</code> call.</p>

<p>Is there a better way to get a listing of a directory in Perl?</p>

In order to get the output of a system command you need to use backticks.
```
```
$listing = `ls`;
```
```
However, Perl is good in dealing with directories for itself. I'd recommend using File::Find::Rule.