in reply to Re^2: Making use of a hash of an array...
in thread Making use of a hash of an array...

Are the brackets used for optional capture at the beginning of my regex confusing what is captured by my $start and $end variables?

Yep (you could have tested this yourself). That is capturing the leading space into $1 and shifting the other two captures down to $2 and $3.

Since you don't need to capture the leading space, don't use parentheses (or, when you must use parentheses but don't want to capture the match, use, um ... non-capturing parentheses, like: (?:foo|bar)). Since you don't know if there will be any matches, use the zero-or-more quantifier. Maybe you want:

/^ \s* $RE{num}{real} \s+ (\d+) \s+ \. \. \s+ (\d+) \s* /x


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^4: Making use of a hash of an array...
by Peter Keystrokes (Beadle) on Jul 19, 2017 at 20:57 UTC
    Aha, thanks.