Paul Johnson wrote: >> >> [panda]# perl -ne 'BEGIN{$/=\10} s/\|\^NEWLINE\^\|\^/\n/g; print' >> [loadFile > > The trouble with this approach is that you will miss any separators > which are split. Your example actually reads 10 bytes at a time, but > using $/ is the right idea: > > perl -ple 'BEGIN { $/="|^NEWLINE^|^" }' loadFile > > This reads "lines" separated by "|^NEWLINE^|^", chomps away the > separator and prints the "lines" followed by a newline. >
thanks for pointing out the obvious. as soon as i hit "Send" i realize both problems you mentioned. OP also noticed this bug. although your solution should work, it's not generalized enough. why? because depends on how the data file is organized and how many newline marks are there in the file, it can eat up a lot of memory as well. consider if OP's loadFile only have a few newline marks and they are all near the end of the file or separated in large chunks. this will cause Perl to keep reading and reading. given this small and unlikely event, i think your solution is perfect. david -- sub'_{print"@_ ";* \ = * __ ,\ & \} sub'__{print"@_ ";* \ = * ___ ,\ & \} sub'___{print"@_ ";* \ = * ____ ,\ & \} sub'____{print"@_,\n"}&{_+Just}(another)->(Perl)->(Hacker) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>