title: Perforce commands Regular Expressions
body: <p>I am having the lines of a perforce command execution as follows:</p>
  
  <pre><code>2806  I deep  sd_bordeaux 117:02:40 IDLE none
  2807  I deep  sd_bordeaux 17:02:40  IDLE none
  2808  I deep  sd_coddeaux 117:02:40 IDLE all
  2809  I rahul sd_coddeaux 117:02:40 IDLE all
  </code></pre>
  
  <p>I have written the following code to run the command to get the above list in $command and store it in a array @lines and use regex to get the specified conditions. But I am not getting the desired results. </p>
  
  <pre><code>my $command = qx |p4 monitor show -ale|;
  my $kill_id;
  my @lines = split("\n", $command);
  for my $line (@lines){
      next if not $line =~ /(\d+)\s+/;
      my $id = $1;
      if ($line =~ /sd_bordeaux\s+(\d+):\d+:\d+\s+/ and $line =~ /IDLE\s+none$/){
          my $hours = $1;
          print "$hours";
          print "\n";
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I am getting an error </p>
  
  <pre><code>Use of uninitialized value $hours in string at ./p4.pl
  </code></pre>
  
  <p>I am interested in getting the numbers "2806" and "2807" as $id and the first digits "117" &amp;  "17" as $hours.</p>
  
  <p>Please can some help me where I am going wrong. Thank you. </p>