lets say I wanted a sliding window to search a file from end to start.²
Could do this with seek and read in a loop.
Now is seek operating on byte boundaries ,but read depends on the encryption layer. °
What's the best way than to read an encoded file, like in UTF-8, backwards ?
Is read fail-proof when accidentally starting inside a wide character after a seek?
Or is it better to open :raw and to search the next character (or line) boundary manually and to decode with Encode then?
I'm aware of File::ReadBackwards , but want to understand the mechanisms better and operate on windows and not lines.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
DB<1> open $fh,'<','input2' DB<2> read $fh => $in, 100 DB<3> p tell $fh 114 # surprise DB<4> open $fh,'<:raw','input2' DB<5> p tell $fh 0 DB<6> read $fh => $in, 100 DB<7> p tell $fh 100 DB<8>
²) I've been asked what I mean with "sliding window", please see this sliding window description. There I start from the beginning, but it's often favorable to start from the end. (choroba++ for pm'ing me)
In reply to Processing an encoded file backwards by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |