in reply to Re: Matching n characters with m//g
in thread Matching n characters with m//g

It still doesn't match. I'm at a loss here. Any ideas how to advance the pos() X characters? then i could just use substr.

my new regex:

$m =~ /\G(.{$sz})/g;

Replies are listed 'Best First'.
Re^3: Matching n characters with m//g
by medium.dave (Novice) on Feb 22, 2016 at 05:08 UTC

    OK, I've managed to solve this, what I now do is use substr() and advance the position of pos(), like so:

    my $cur_pos = pos($m); print $FH substr($m, $cur_pos, $sz); pos($m) = $cur_pos + $sz;

    works great!