How can I rewind the start of the next search position by 1? For example, suppose I want to match all digits between #
. The following will give me only odd numbers.
my $data="#1#2#3#4#";
while ( $data =~ /#(\d)#/g ) {
print $1, "\n";
}
But if I could rewind the start of the next position by 1, I would get both even and odd numbers.
This doesn't work: pos() = pos() - 1;
I know I can accomplish this using split
. But this doesn't answer my question.
for (split /#/, $data) {
print $_, "\n";
}