title: Missmatch in array comparison error message ' Argument "" isn't numeric in array element at'
body: <p>I am very new to perl and am struggling to get this script to work.</p>
  
  <p>I have taken pieces or perl and gooten them to work as indivual sections but upon trying to blend them together it fails. Even with the error messages that show up I can not find where my mistake is.</p>
  
  <p>The script when working and completed will read an output file and go through it section my section and utilmately generate a new output file with not much more the a heading with some additional text and a value of the amount of lines in that section.</p>
  
  <p>My issues are when it does the looping for each keyword in the array it is now failing with the error message 'Argument "" isn't numeric in array element at'. Perl directs me to a section in the script but I can not see how I am calling the element incorrectly. All the elements in the array are alpha yet the error message is refering to a numeric value.</p>
  
  <p>Can anyone see my mistake.</p>
  
  <p>Thank you</p>
  
  <p>Here is the script</p>
  
  <pre><code>#!/usr/bin/perl -w
  use strict;
  use warnings;
  use diagnostics;
  # this version reads each variable and loops through the 18 times put only displays on per loop. 
  
  my $NODE = `uname -n`;
  my $a = "/tmp/";
  my $b = $NODE ;
  my $c = "_deco.txt";
  my $d = "_deco_mini.txt";
  chomp $b;
  my $STRING = "$a$b$c";
  my $STRING_out = "$a$b$d";
  
  my @keyword = ( "Report", "Last", "HP", "sulog", "sudo", "eTrust", "proftp", "process", "active clusters", "pdos", "syslog", "BNY", "syslogmon", "errpt", "ports", "crontab", "NFS", "scripts", "messages");
  
  my $i = 0;
  my $keyword="";
  my $x=0;
  my $y=0;
  my $jw="";
  
  my $EOS = "########################################################################";
  my $qty_lines=0;
  my $skip5=0;
  my $skipcnt=0;
  my $keeplines=0;
  my @HPLOG="";
  
  do {
      print "Reading File: [$STRING]\n";
  
      if (-e "$STRING" &amp;&amp; open (IN, "$STRING")) {
  #       ++$x;                              # proving my loop worked
  #       print "$x interal loop counter\n"; # proving my loop worked
          for ( ++$i) { # working
              while ( &lt;IN&gt; ) {
                  chomp ;
                  #if ($_ =~ /$keyword/) {
                  #if ($_ =~ / $i /) {
                  #if ($_ =~ /$keyword[ $i ]/) {
                  if ($_ =~ /$keyword $i/) {
                      print "  $i \n";
                      $skip5=1;
                      next;
  #                   print "$_\n";# $ not initalized error when tring to use it 
                  }
  
                  if ($skip5) {
                      $skipcnt++;
                      print "SKIP LINE: $_\n";
                      print "Header LINE: $_\n";
                      next if $skipcnt &lt;= 5;
                      $skip5=0;
                      $keeplines=1;
                  }
  
                  if ($keeplines) {
  #                   ++$qty_lines;                # for final output
                      last if $_ =~ /$EOS/;
                      print "KEEP LINE: $_\n";
  #                   print "$qty_lines\n";      # for final output
  
                      push @HPLOG, "$_\n";
                      # push @HPLOG, "$qty_lines\n";# for final output
                  }
              } ## end while ( &lt;IN&gt; )
          } ## end for ( ++$i)
      } ## end if (-e "$STRING" &amp;&amp; open (IN, "$STRING"))
  
      close (IN);
  } while ( $i &lt; 19 &amp;&amp;  ++$y &lt; 18 );
  </code></pre>
  
  <p>Here is a sample section or the input file.
      ###############################################################################</p>
  
  <pre><code>                       Checking for active clusters.
  
                                  @@@@@@@@@
  
    root 11730980 12189848   0 11:24:20  pts/2  0:00 egrep hagsd|harnad|HACMP|haemd
  
   If there are any processes listed you need to remove the server from the cluster.
  
  ############################################################################
  
                         This is the output from Pdos log
  
  Please review it for anything that looks like a users may be trying to run something.
  
                                  @@@@@@@@@
  
                          This server is not on Tamos 
  
  ############################################################################
  
                          This is the output from syslog.conf.
  
  Look for any entries on the right side column that are not the ususal logs or location.
  
                                   @@@@@@@@@
  
  # @(#)34    1.11  src/bos/etc/syslog/syslog.conf, cmdnet, bos610 4/27/04 14:47:53
  # IBM_PROLOG_BEGIN_TAG 
  # This is an automatically generated prolog. 
  #  
  # bos610 src/bos/etc/syslog/syslog.conf 1.11 
  </code></pre>
  
  <p>I truncated the rest of the file</p>