Codes goes along this way :

$current_record = $_;

if (substr($current_record, 0, 6) eq 'GRSUMC') {

   # Remove new line marker
   chomp($current_record = $current_record);
                        
   # Attach run no to end of record
   $current_record = $current_record . $run_no . "\n";
   }
            
    print OUTPUT $current_record;               


I haven't touched the $/ variable (didn't even know of it until now!).
Thing is, this code works fine for every file I have received - except for the latest 
file I received on Friday. Chomp doesnt work on the latest file which ends in the 
0d0a. Maybe my code is not correct or unstable ?

-----Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Friday, 23 July 2004 22:17
To: David Clarke; [EMAIL PROTECTED]
Subject: RE: New Line / Chomp Query


David Clarke wrote:
> Hi, does anyone know what the new line character value is in Hex for
> a text file ? Is it "0d 0a" ? 

ASCII newline is 0x0A (decimal 10)

On Unix-ish systems, text files end each line with a single newline.

On Windows systems, text files end each line with a CR/LF pair (0x0D, 0x0A).
However, the underlying stdio library translates this into a single newline
on input and translates it back to a CR/LF pair on output (unless you've
called binmode on the handle). So from your program's perspective, you still
have a single newline at the end of each line.

On Mac systems, the terminator is something different (not sure what), but
the same concept applies as for Windows AFAIK.

> 
> I'm trying to read in a line of text, chomp it, attach 3 digits at
> the end of this line, then write this line to output file. But when I
> write it out, the original input line is written out, then a new line
> occurs, then my 3 digits appear on a second line. Shouldn't chomp
> remove the new line indicator from the input text? Im completely
> baffled. Thanks.    

chomp() removes the line terminator as defined by the special $/ variable.
If you haven't messed with $/, it should be working. Let's see your code.


***********************************************************************************
This e-mail, including any attachments to it, may contain confidential and/or personal 
information.
If you have received this e-mail in error, you must not copy, distribute, or disclose 
it, use or take any action 
based on the information contained within it.

Please notify the sender immediately by return e-mail of the error and then delete the 
original e-mail.

The information contained within this e-mail may be solely the opinion of the sender 
and may not necessarily 
reflect the position, beliefs or opinions of Salmat on any issue.

This email has been swept for the presence of computer viruses known to Salmat's 
anti-virus systems.

For more information, visit our website at  www.salmat.com.au.
***********************************************************************************


--
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