title: Getting uninitialized error when running my perl script
body: <p>I am entering the first argument as "-d" and the second argument is a directory as long as it is a valid directory name.</p>
  
  <p>Below is a snip of my code:</p>
  
  <pre class="lang-perl prettyprint-override"><code>if ($ARGV[0] eq "-d" &amp;&amp; -d $ARGV[1]){
          print "File Names       Size    Owner   Group\n";
          if (-d $ARGV[1]){
              my $newdir = ARGV[1];
              opendir(DIR, $newdir) or die $!;
          while (my  $file = readdir(DIR)){
                  my $filename = "$file";
                  my $size = -s $filename;
                  my $gid = (stat("$file"))[5];
                  my $group = getgrgid($gid);
                  next if ($file =~ m/^\./);
                  print "$file    $size   $gid    $group\n";
          }
          closedir(DIR);
      }
  }
  </code></pre>
  
  <p>I am trying to return a list of all the file names, the file size, the file owner, and the group owner. When I execute the script it returns the file names, but i get errors for the size and owners. The specific error is </p>
  
  <pre class="lang-none prettyprint-override"><code>Use of uninitialized value $gid in getgrgid at ./tester.pl line 73.
  Use of uninitialized value $size in concatenation (.) or string at ./tester.pl line 75.
  Use of uninitialized value $gid in concatenation (.) or string at ./tester.pl line 75.
  </code></pre>
  
  <p>I am not sure why it is stating the <code>$gid</code> and <code>$size</code> variables are not initialized</p>