in reply to Re: *.opml file output to console problem
in thread *.opml file output to console problem

Sorry for the inconvenience, I want the exact opml text from the file in my string like this:

<?xml version="1.0" encoding="ISO-8859-1"?> <opml version="2.0"> <head> <title>workspace.userlandsamples.doSomeUpstreaming</title> <dateCreated>Mon, 11 Feb 2002 22:48:02 GMT</dateCreated> <dateModified>Sun, 30 Oct 2005 03:30:17 GMT</dateModified> <ownerName>Dave Winer</ownerName> <ownerEmail>dwiner@yahoo.com</ownerEmail> <expansionState>1, 2, 4</expansionState> <vertScrollState>1</vertScrollState> <windowTop>74</windowTop> <windowLeft>41</windowLeft> <windowBottom>314</windowBottom> <windowRight>475</windowRight> </head> <body> <outline text="Changes" isComment="true"> <outline text="1/3/02; 4:54:25 PM by DW"> <outline text="Change &quot;playlist&quot; to &quot;ra +dio&quot;."/> </outline> <outline text="2/12/01; 1:49:33 PM by DW" isComment="true" +> <outline text="Test upstreaming by sprinkling a few fi +les in a nice new test folder."/> </outline> </outline> <outline text="on writetestfile (f, size)"> <outline text="file.surefilepath (f)" isBreakpoint="true"/ +> <outline text="file.writewholefile (f, string.filledstring + (&quot;x&quot;, size))"/> </outline> <outline text="local (folder = user.radio.prefs.wwwfolder + &q +uot;test\\largefiles\\&quot;)"/> <outline text="for ch = 'a' to 'z'"> <outline text="writetestfile (folder + ch + &quot;.html&qu +ot;, random (1000, 16000))"/> </outline> </body> </opml>

use my perl code print out in console I got:

<opml ve</opml>2</body>e</outline>ext="writetestfile (folder + ch + &q +uot;.html&quot;, random (1000, 16000))"/>lder."/>
it seems like a encoding problem, which I have no experience. So I wonder, how do I read such a file and properly stored in a perl string? This is a homework. Am not allow to use any module.

Replies are listed 'Best First'.
Re^3: *.opml file output to console problem
by tobyink (Canon) on May 13, 2012 at 19:17 UTC

    At a guess you've got a mismatch between the line endings that Perl is outputting, and the line endings supported by your console. I imagine that if you redirect the output of your script into a file, then the file will look sensible.

    perl myscript.pl > myoutput.txt

    ... and then open myoutput.txt in a decent text editor.

    In particular, I think your OPML file currently has Macintosh-style line endings.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      This helps, Thanks