http://www.perlmonks.org?node_id=26313
Description: I ran across this while I was trying to locate the spaces in a row of dashes in a header line to find the placement of the columns in a formatted text report. Note that I could not just use a split in the body of the report because some entries were missing, and I had to do this for a lot of reports so I needed the process to be dynamic.

The result shows why it is good to know what /g does in scalar mode, and why pos() is a nice function to have.

This builds an array of the locations right after the space. This was perfect for me since I wanted to know where the next column would begin, but that is not always the ideal choice.

my @pos;
while ($line =~ / /g) {
    push @pos, pos($line);
}