medium.dave has asked for the wisdom of the Perl Monks concerning the following question:
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 :-(
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching n characters with m//g
by Athanasius (Archbishop) on Feb 22, 2016 at 03:44 UTC | |
by medium.dave (Novice) on Feb 22, 2016 at 05:06 UTC | |
by medium.dave (Novice) on Feb 22, 2016 at 05:08 UTC | |
|
Re: Matching n characters with m//g
by kcott (Archbishop) on Feb 22, 2016 at 03:55 UTC | |
by medium.dave (Novice) on Feb 22, 2016 at 04:25 UTC | |
by kcott (Archbishop) on Feb 22, 2016 at 06:05 UTC | |
|
Re: Matching n characters with m//g
by AnomalousMonk (Archbishop) on Feb 22, 2016 at 08:13 UTC | |
|
Re: Matching n characters with m//g
by AnomalousMonk (Archbishop) on Feb 22, 2016 at 08:52 UTC | |
|
Re: Matching n characters with m//g
by ikegami (Patriarch) on Feb 24, 2016 at 12:11 UTC | |
|
Re: Matching n characters with m//g
by Anonymous Monk on Feb 22, 2016 at 14:58 UTC |