Computing.Net > Forums > Programming > Removing Nulls using Perl script

Removing Nulls using Perl script

Reply to Message Icon

Original Message
Name: jpm
Date: August 30, 2007 at 07:24:36 Pacific
Subject: Removing Nulls using Perl script
OS: HPUX
CPU/Ram: PA RISC 800 MHz/1.5 MB ca
Model/Manufacturer: RP4440
Comment:

Hello
I'm trying to remove null characters from a text file. I can resolve this by manually opening and saving the file with vi.However I want to do this automatically in a Perl script.What I have so far :
# Go through each line of find output
# psLine contains a file reference
# eg /temp/TextFile
foreach $psLine (@ps)
{
# Translate the TextFile to remove nulls
print $psLine;

}

jpm


Report Offensive Message For Removal


Response Number 1
Name: FishMonger
Date: August 30, 2007 at 09:33:42 Pacific
Subject: Removing Nulls using Perl script
Reply: (edit)

In vi the null char displays as ^@ is that what you're wanting to remove or is it ^M from the end of the line?


Report Offensive Follow Up For Removal

Response Number 2
Name: jpm
Date: August 31, 2007 at 06:51:06 Pacific
Subject: Removing Nulls using Perl script
Reply: (edit)

Hi FishMonger,
The character I'm replacing is an ASCII null or NUL value which is 00. I cannot actually see the character with vi but when I open a file with the problem I see a message at the bottom indicating the quantity of nulls. Just doing :wq! clears the nulls from the file. In unix I have managed to delete the nulls by translating the file to another with the command
tr -d "\000" <TextFile >tempfile
What would be the equivalent in Perl ?
Thanks for replying.

jpm


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Removing Nulls using Perl script

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 3 Days.
Discuss in The Lounge