Pattern Matching in file with invisible char

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Pattern Matching in file with invisible char

    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 Guest

  2. Similar Questions and Discussions

    1. file path pattern matching problem.
      Hi all, I'm trying to split apart a filepath...e.g: c:\test\abc\what\somefile.txt The length of the filepath will never be constant... e.g:...
    2. pattern matching
      brian liu <xliu75@yahoo.com> wrote: or $defaultDir='d:/haha'; or
    3. Pattern Matching Operators
      Is there a similar operator in Perl for ${variable##pattern} as there is in korn shell. Thanks for the help. Prasad ...
    4. [PHP] mysql Pattern Matching
      From: "Ralph Guzman" <ralph213@sbcglobal.net> Actually no, I guess there isn't. Neither one will use an index. mysql> desc test;...
    5. mysql Pattern Matching
      i'm doin this offlist -----Original Message----- From: Ralph Guzman Sent: Thursday, September 04, 2003 10:23 PM To: PHP General Mailing List...
  3. #2

    Default Re: Pattern Matching in file with invisible char

    M Pires <MIGUEL.PIRES@PORTUGALMAIL.PT> 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
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  4. #3

    Default Re: Pattern Matching in file with invisible char

    [email]tadmc@augustmail.com[/email] (Tad McClellan) wrote in message news:<slrnbmectb.4jq.tadmc@magna.augustmail.com>.. .
    > > 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 Guest

  5. #4

    Default Re: Pattern Matching in file with invisible char

    M Pires <MIGUEL.PIRES@PORTUGALMAIL.PT> wrote:
    > [email]tadmc@augustmail.com[/email] (Tad McClellan) wrote in message news:<slrnbmectb.4jq.tadmc@magna.augustmail.com>.. .
    >
    >> > 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
    [email]tadmc@augustmail.com[/email] Perl programming
    Fort Worth, Texas
    Tad McClellan Guest

  6. #5

    Default Re: Pattern Matching in file with invisible char

    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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139