in reply to Parsing a text file

What are you trying to do? I don't understand why you're messing with the input record separator ($/).

With a |-delimited file, something like this works:

while(<>) { chomp; my @array = split(/\|/); }

and who cares if any of the elements in @array have \r?

If you're looking to strip \r out of your text, it's just what you'd think it would be:

s/\r//g;

(Welcome to perlmonks!)

Update Ah, I see. Ack! I hate dealing with sloppy data :)

Replies are listed 'Best First'.
Re: Re: Parsing a text file
by rgatliff (Sexton) on Feb 10, 2001 at 16:13 UTC
    eg- The reason I was messing with the input record seperator was because the text in the fields of the file seemed to contain the default record seperator. If I loaded the data file in Xemacs, it would show the problem text fields containing ^M where as the records themselves were seperated with a return. Both the record seperator and the problem text areas showed as "0D 0A" in a hex editor, so I guess they are identical. I am sure I am missing a simple thing here, but using $/ as "|\n" (every record finishes with a |) is working. Thanks for the reply. I hope I have not made too much of an idiot of myself on my first post....