![]() |
|
good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re^2: substr is behaving differently with small vs large stringsby perldeveloper (Scribe) |
on Jul 07, 2004 at 21:32 UTC ( #372559=note: print w/replies, xml ) | Need Help?? |
The offset appears to make sense in the trimmed file. That is, excluding the spaces between the columns and the line numbers. Which suggests that Augustine might aviod slurping the file, by reading one line at a time (by leaving $/ unchanged) and windowing every input sequence (exon) (a sequence of lines which covers the exon). You could also use `seek' and `sysread' (as suggested by Belgarion, but you'd have to work out an algorithm (quite simple I would guess) which converts the address within the trimmed file to the address within the formatted file. Something like... $address_in_file = $address_in_trimmed_file + $number_of_characters_for_line_numbering_for_first_line + ($address_in_trimmed_file / 10) + ($address_in_trimmed_file / 60) * ($one_character_for_new_line + $number_of_characters_for_line_numbering). Actually, I think that is a correct and yet unabusive way to solve this (every 10 characters you get a space, every 60 characters you get a new line and a line number). On another note, though, I have experience with slurping large files, and can say that perl handles it pretty good. For example, I could semi-parse an 8Mb Xml file into an internal tree within seconds. I'm afraid I cannot say how substring handles large offset/length parameters, I thought it would work as expected.
In Section
Seekers of Perl Wisdom
|
|