Andrew Westcott wrote:
>
> You have solved my problem, the key was in your script. I had not been
> reading the file in binary mode and so the different LF and CR where getting
> lost.
>
> Thanks
>
> I did run the script you sent which was very help full and I will store that
> away as I'm sure it will come in use.
>
> Script output
>
> Obj_ID
> 09
> In_link
> 0d    0a
> WBX586
> 09
> 2SV_WBX123
> 0d    0a
> WBX2367
> 09
> 2SV_WBX123
> 0d    0a
> WBX2428
> 09
> 2SV_WBX123
> 0a
> WBX_APPS169
> 0d    0a
> WBX588
> 09
> 2SV_WBX123
> 0d    0a
> WBX2432
> 09
> 2SV_WBX123
> 0d    0a
> WBX589
> 09
> 2SV_WBX123
> 0d    0a
> WBX2433
> 09
> 2SV_WBX123
> 0d    0a
>
>
> so it would appear I have
>
> field1_1 <TAB> field2_1 <LF> field2_2 <LF> .... field2_x <CR> <LF>
>
> With the binmode I can replace the LF with commas and then my script is ok.

OK, but you still haven't solved the problem. Joseph's intent was
to show you how to examine the raw data, but I doubt he would
expect you to process a text file in that way.

My guess is that you're running on Unix but reading a file that
was imported from a Windows system, where <CR><LF> is the line
termination.

IMO you should remove

  local $/;
and
  binmode FILEHANDLE;

and write instead

  while (<FILEHANDLE>) {
    tr/\r//d;  # Work-around Windows terminators
    my @fields = split;
  }

to process the data record-by-record but trash all <CR>
characters on their way in.

I really hope that this doesn't fall on deaf ears. So many
people grab hold of anything that works without considering
how their script reads. A solution like, "Hey, if I read this
text file in binary mode and replace all the LFs with commas
it all works fine!!", doesn't warm my heart in any way.

(Joseph will, of course, agree, and post to endorse this and
to ban any other out-of-context plagiarism of his code. Won't
you Joseph?)

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to