{ local $_= <DATA>; while( defined $_ ) { chomp; s/(.)G57/$1\nG57/g; print $1 if s/(.*\n)//s; if( ! /G5?$/ ) { print $_,$/ if "" ne $_; $_= <DATA>; } else { my $next= <DATA>; last unless defined $next; $_ .= $next; } } print $_,$/; } __END__ dasdfdafdsfadfdfaG57ewefdsfsdfsG 57dfadfasdfasdfsffdasG57dfsafdsf sG57dfafdafdsfadfafdfasdfasdfasf dafdfasdfasdfdsafasdfsdafasdfads dfadfasfdsdfadfasdfasfdadsfasfdd G57dsafdsfasdfadsfasdfadfadfadff dfdf
This produces:
rather than what you asked for because it doesn't "join" lines unless it has to in order to match the string.dasdfdafdsfadfdfa G57ewefdsfsdfs G57dfadfasdfasdfsffdas G57dfsafdsf s G57dfafdafdsfadfafdfasdfasdfasf dafdfasdfasdfdsafasdfsdafasdfads dfadfasfdsdfadfasdfasfdadsfasfdd G57dsafdsfasdfadsfasdfadfadfadff dfdf
Update: This node briefly showed incorrect code because I forgot to paste the tested code back in.
- tye (but my friends call me "Tye")In reply to (tye)Re: How to look for patterns in a file and create a CR
by tye
in thread How to look for patterns in a file and create a CR
by juo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |