in reply to Re: Input Record Separator WON'T WORK!
in thread Input Record Separator WON'T WORK!

Okay, everybody, it works! Here's the lowdown. It was a text-encoding problem. UTF-8 and UTF-16 weren't cooperating. Duh. also explains why just ONE character worked.... Seems like perl could deal with 0000000012345678 as an 8bit value, but a STRING of those (000000001234567800000000685708540000000064739567) was thought to be 00000000, 12345678, 00000000, 68570854, etc, which obviously DIDN'T match. I'm happy to have resovled this one. That's correct about the for/vs while. Oops! Thanks. And yes, I'm constantly reminded to consult CPAN. But, I'm just learning perl. I'm not using modules; I'm writing everything myself. The more code you write, the more you learn. I know it's reinventing the wheel. That's how you learn! "Good programmers write good programs, great programmers steal great programmers." Obviously. I'm trying to learn to be a good programmer before I become a great programmer. Thanks for your help everyone!

Replies are listed 'Best First'.
Re: It works!
by ikegami (Patriarch) on Jan 25, 2008 at 01:57 UTC

    Using the IRS fails in the following situations:

    <student><!-- </student> -->...</student>
    <student>...</student >
    <student />

    And possibly more. (charset? entities?)

    Also, it fails miserably (i.e. reads the entire file into memory) at detecting errors.

    If you really do wish to reinvent the wheel, time to learn and start using something else.

      This is still in the earliest stage... Obiously, it does absolutely nothing right now. But it will! It will be changed immensely. No worries. ... I don't understand what you mean by that last line....? what do you mean "time to learn and use something else?" Learn... what? Use "something else" as opposed to.... what am I using now? ...?

        He means that if you are going to parse an XML file, use an XML module from CPAN because it already handles all the funky cases you will end up needing to handle and that if you want to reinvent the wheel (re-code and debug all the parts already done in a module) then you'll have to learn some new skills because IRS isn't going to cut it. ;)

        You mentioned wanting to be a good programmer before using modules, in Perl, using modules is a big part of being a good programmer.


        ___________
        Eric Hodges
        The input would need to be processed in order (char by char, then token by token). Using a parser generator (e.g. Parse::RecDescent and a good book on parsing) will help a lot, while still leaving much to learn.