in reply to counting leading white spaces

"Counting whitespace" doesn't make much sense. Did you mean "counting whitespace characters"?

/^(\s*)/ && length($1)

Update: Presuming a scalar context,

() = /\G\s/g

also works.

Replies are listed 'Best First'.
Re^2: counting leading white spaces
by jwkrahn (Abbot) on Feb 11, 2009 at 20:20 UTC
Re^2: counting leading white spaces
by Anonymous Monk on Nov 10, 2015 at 19:53 UTC
    what does () = /\G\s/g do??