in reply to Re^2: extract the value before a particualr string
in thread extract the value before a particualr string

$1 holds the result of the pattern match captured inside (parenthesis). If you had multiple parens then there would also be a $2, $3, etc. The $/ variable is the input record separator, this defaults to being a newline, so print $_,$/ is equivalent to print "$_\n". The $ after total tells the regex engine that total will be the last thing on the line.

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^4: extract the value before a particualr string
by Anonymous Monk on Sep 05, 2013 at 11:40 UTC

    So, if we need to do the operation on a variable line and assign the output to a variable how do we go abt it???

    $count = $line if/\s+?(\d+?)\/total$/;

    will this look fine?

      No, that would be

      $count = $1 if $line =~ /\s+?(\d+?)\/total$/;