title: Regular expression to parse the command output
body: <p>I have created a function to parse the output of a command.</p>
  
  <p>The output of the command will be the following :</p>
  
  <pre><code> Host-profile-count   User       114 
  </code></pre>
  
  <p>( Note: the  number 114  is not constant.it could be any positive number >= 0 )</p>
  
  <p>Now i just need the number ( in this case 114)  to be returned.
  I guess the regex in my script is wrong. When i run the script i get the output as 0. It should be 114.
  Can somebody help me out with the regex please ?</p>
  
  <pre><code>sub _count {
  
     my ($self) = @_;
     my  $cmd   = 'command goes here ';
     my  $profiles = 0;
  
     $self-&gt;execute($cmd);
  
    foreach my $line ( @{ $self-&gt;get_stdout() } ) {
         if ( $line =~ m/Host\sprofile\scount\s+\S*\s+(\S*)/msx ) {
              $profiles = $1;
          }
      }
  
      $profiles =~ s/^\s+|\s+$//msxg;
      return $profiles;
  }
  </code></pre>