#!/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"; }