while ($firstrow =~ /(<\w>)/g) { push @columnpos, pos($firstrow) - length($1); }
You could use a look-ahead to avoid doing the capture, length and subtraction.
push @columnpos, pos $firstrow while $firstrow =~ m{(?=<\w>)}g;
I hope this is of interest.
Cheers,
JohnGG
In reply to Re^2: How to find start position of each column
by johngg
in thread How to find start position of each column
by Gangabass
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |