Hi all. I have a "really long string" with many parts to it (something like an IMAP response that needs to be manually processed). So it has sections like:
So, I need to work through each part of the string, which I am doing just fine. However, when I come to the part "RFC822.TEXT {234565}" I now need to read exactly 234565 from the string. I am processing this with the m//g operator, so each time I call m//g it matches the string from where I left off the last match. So the code I have, to work through the string, because there is a limit to the n-times match of 32766, is the following:FLAGS (\Seen) UID 42 RFC822.TEXT {234565} this is a bunch of string data, but it also contains some binary data...it's not actually IMAP code, it's an internal app that works similarly, but a lot more people are more familiar with IMAP... ..snip.. a lot more string RFC822.SIZE 234565 INTERNALDATE " 21 FEB 2016 12:23:23 +1000")
while( $sz > 32760 ) { $m =~ /(^.{32760})/g; print $FH $1; $sz -= 32760; } $m =~ /(^.{$sz})/g; print $FH $1;
...except the m/(^.{32760})/g isn't matching, and the string pos() is being reset.
Any ideas why? Your input would be gratefully be accepted, I've been banging away at this with various incarnations for more hours than I care to admit :-(
In reply to Matching n characters with m//g by medium.dave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |