> -----Original Message-----
> From: Pradeep Sethi [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 10, 2001 8:49 PM
> To: [EMAIL PROTECTED]
> Subject: getting lines from a file
> 
> 
> With this code, I get :
> 
> #!/usr/bin/perl -w
> 
> my $ordfile=shift || die "unable to open : $!s\n";
> 
> open (LIST, "<$ordfile") || die "unable to open file $ordfile : $!\n";
> 
> 
> while (<LIST>) {
> #  chomp;      # a)
>   my $line=$_;
>   print STDERR "\nline : *** $line ***";
> }
> 
> 
> line : *** 6M2FD9XV 
>  ***
> line : *** A9Q2YFU8 
>  ***
> line : *** BDE6MDBJ 
>  ***
> 
> If I chang line a) to chomp, I  get
> 
>  ***line : *** 6M2FD9XV 
>  ***line : *** A9Q2YFU8 
>  ***line : *** BDE6MDBJ 
> 
> Can somebody explain, what do I need to get lines as complete 
> words with
> line breaks etc.

Hard to say for certain, but it looks like your lines may be
ending with \r\n, and chomp is removing \n and leaving \r.

You can remove trailing \r with:

   s/\r$//;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to