Pattern Matching in file with invisible char

Discussion in 'Perl Misc' started by M Pires, Sep 16, 2003.

  1. M Pires

    M Pires Guest

    Hi there,

    First of all, I am sorry if this is a FAQ. I couldn't find anything in the
    PerlDoc, so if I missed something please be kind enough to redirect me to
    it!

    I am currently working on a Perl script that will parse out values from an
    "almost" text file. The reason I say this is because there are "invisible"
    chars in the file such as the ASCII SUB char ( 0x1A ). This chars confuse
    the <HANDLE> and cause a premature EOF.

    Is there a way around this?

    Thx a lot!
    M Pires, Sep 16, 2003
    #1
    1. Advertising

  2. M Pires <> wrote:

    > I am currently working on a Perl script that will parse out values from an
    > "almost" text file.



    Then it is a binary file.


    > The reason I say this is because there are "invisible"
    > chars in the file such as the ASCII SUB char ( 0x1A ). This chars confuse
    > the <HANDLE> and cause a premature EOF.



    Since we are concerned with files, it might be helpful to know what
    OS is being used, as the operating system is what manages the filesystem.


    > Is there a way around this?



    perldoc -f binmode


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Sep 16, 2003
    #2
    1. Advertising

  3. M Pires

    M Pires Guest

    (Tad McClellan) wrote in message news:<>...

    > > Is there a way around this?

    >
    >
    > perldoc -f binmode


    Thank you very much! For reference the OS is W2K but your tip worked
    like a charm. It's frustrating when the answer was in front of you all
    along...!
    M Pires, Sep 17, 2003
    #3
  4. M Pires <> wrote:
    > (Tad McClellan) wrote in message news:<>...
    >
    >> > Is there a way around this?

    >>
    >>
    >> perldoc -f binmode

    >
    > Thank you very much! For reference the OS is W2K but your tip worked
    > like a charm. It's frustrating when the answer was in front of you all
    > along...!



    Often, all it takes is trying a bunch of different search terms.

    perldoc -q binary

    would have done it for you in this case...


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Sep 17, 2003
    #4
  5. M Pires

    Bart Lateur Guest

    M Pires wrote:

    >I am currently working on a Perl script that will parse out values from an
    >"almost" text file. The reason I say this is because there are "invisible"
    >chars in the file such as the ASCII SUB char ( 0x1A ). This chars confuse
    >the <HANDLE> and cause a premature EOF.


    It's not quite premature... On ancient systems (think DOS and earlier)
    this was used as a end-of-file marker on text files. That's why
    binmode() fixes this.

    Don't forget you'll now have to delete unnecessary CR characters (=
    "\r") yourself.

    --
    Bart.
    Bart Lateur, Sep 18, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lovecreatesbeauty
    Replies:
    1
    Views:
    1,012
    Ian Collins
    May 9, 2006
  2. Andy B
    Replies:
    5
    Views:
    574
    Andy B
    May 29, 2008
  3. Marc Bissonnette

    Pattern matching : not matching problem

    Marc Bissonnette, Jan 8, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    220
    Marc Bissonnette
    Jan 13, 2004
  4. Bobby Chamness
    Replies:
    2
    Views:
    215
    Xicheng Jia
    May 3, 2007
  5. nani
    Replies:
    2
    Views:
    155
    comp.llang.perl.moderated
    Mar 14, 2008
Loading...

Share This Page