For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2006 > Re: How to split a file on the CR carriage Return and/or









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: How to split a file on the CR carriage Return and/or
Steve Pittman

2006-07-28, 9:56 pm

Thanks to everyone for your suggestions....

I replaced the INPUT_RECORD_SEPARATOR ($/) as suggested....

My script is working great!!

Thanks Very Much!!!

Steve

On Jul 26, 2006, at 2:59 PM, Steve Pittman wrote:[color=darkred]
> I am using activestate on a windows box ...the files I am parsing

are
> Unix files...I tried this so far...
>
> open ( IN, "<$_[0]" )||die "Can't open DAT source file: $tempFile
> $!\n";
> while (<IN> ){s/\r/\n/g;@lines = <IN>;}#
> close (IN);
>
> foreach $line (@lines)
> {


Try a different value for the INPUT_RECORD_SEPARATOR ($/):

$/="\n" ;
open ( IN, "<$_[0]" ) or die "Can't open DAT source file: $tempFile $!

\n" ;
my @lines = <IN> ;
foreach $line (@lines)
{ ...

Notice that I also changed the || to "or".

Let us know what you try and how it works for you.

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software. Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com