Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: To read Char-by-Char from a file

by Anonymous Monk
on Apr 05, 2018 at 21:39 UTC ( [id://1212382]=note: print w/replies, xml ) Need Help??


in reply to To read Char-by-Char from a file

Some of us like to do things ourselves, without shopping around for a pre-built library with pages of syntax and options. A simple and braindead way of reformatting things like xml or Oracle tnsnames.ora entries is to count opening and closing delimiters to determine where to use tabs, CR's, etc. Reading one charcter at a time makes this somewhat easy. In this case it doesn't matter if the file is being buffered or not because decisions about the output, not input, are being made per character.

Replies are listed 'Best First'.
Re^2: To read Char-by-Char from a file
by choroba (Cardinal) on Apr 05, 2018 at 21:54 UTC
    Unfortunately, some important syntax constructs in XML are longer than one character (e.g. <!-- or <![CDATA[ and their closing counterparts), but they can change how the following < should be interpreted. Good luck with implementing your own XML parser!

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1212382]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (None)
    As of 2024-04-25 00:02 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found