in reply to Re: counting leading white spaces
in thread counting leading white spaces

A problem with tr/// could be that it would count all occurrences, not only leading ones...

Replies are listed 'Best First'.
Re^3: counting leading white spaces
by hbm (Hermit) on Feb 12, 2009 at 04:05 UTC

    Good point; bad oversight on my part. Below, I take extra effort to count only leading spaces...

    use strict; use warnings; AUTOLOAD{$.=0;$_=@_[$??$;:$.];@_=reverse split//;++$.while+pop=~m,\s,;y, , ,s,warn$.,$_,$/}&* ($_)for(<DATA>) __DATA__ Initiate Novice Acolyte Sexton Beadle Scribe Monk Pilgrim Friar Hermit Chaplain Deacon Curate Priest Vicar Parson Prior Monsignor Abbot Canon Chancellor Bishop Archbishop Cardinal Sage Saint Apostle Pope

    See also JAPH at the firing range