title: Perl - Checking for file from array exists in directory
body: <p>I'm trying to get the contents of an <code>ls</code> command in Linux out to the command line using an array. Only issue I'm getting is, that when the files are looked over using an <code>if</code> statement, it seems to be only searching in the PWD of the script and not the path specified. </p>
  
  <p>Right now my code looks like this:</p>
  
  <pre><code>my $directory = $ARGV[0];
  chomp (my @files = `ls -a $directory`);
  my @plainfiles;
  my @directories;
  if (-f $_) {
      push (@plainflies, $_);
  }
  elsif (-d $_) {
      push (@directories, $_);
  }
  </code></pre>
  
  <p>Any ideas?</p>