The answer really depends on whether you're trying to learn about populating arrays and are using the output of ls as an example, or trying to list files in a directory and get those into your program.
If the main aim is to get the list of files into your program, I'd recommend pelagic's answer. The opendir documentation has boilerplate code that you can copy into your program and modify to suit your needs. It's normally better in terms of efficiency, powerfulness and control over what's going on to do things like this internally in Perl (which is what opendir does) where you can, rather than running an external shell command to get the same data and then parsing its text output.
If you're learning about arrays, then the backticks & the glob work, as would using an open which allows you to process the output of the command on the way into your array.
e.g.:
#!/usr/bin/perl
#
#
#
use warnings;
use strict;
my @files;
open (my $ls_fh, "/bin/ls|") || die "Can't run '/bin/ls': $!\n";
while (defined (my $line = <$ls_fh>)) {
#
next if $line =~ /pattern_I_want_to_ignore/;
chomp $line;
push @files, $line;
}
close $ls_fh;
print "Third file: $files[2]\n";
for my $file ( @files ) {
print "$file\n";
}