|
Posted by John Bokma on June 4, 2005, 12:06 am
Please log in for more thread options
Eben wrote:
> Tips from a previous thread helped me with this task. The previous
> thread:
> http://groups-
beta.google.com/group/comp.lang.perl.modules/browse_frm/t
> hread/64c79e909fb9cc14/0aa566545d90faa2?
q=removing+NON+PRINTABLE+CHARAC
> TERS&rnum=1&hl=en#0aa566545d90faa2
>
> To give back to the community, my two bits on how to <replace>
> nonprintable characters in a file. Simple for you perl gurus, but for
> perl newbies like me this makes my day!
>
> ---<code begin>---
>
> # to replace the non printable characters in a file...
>
> $filename = "/AIH/TEMPDATA/PMFEXT";
> $fileout = "/AIH/TEMPDATA/PMFEXT2";
> open(OUT, ">$fileout");
check
> open(IN, "<$filename");
check
> $_ = <IN>; #read the first line
> s/[^[:print:]]/ /g;
> print OUT "$_";
why did you do this, since you are going to loop?
> while(<IN>) { #loop as long as not EOF
> s/[^[:print:]]/ /g;
> print OUT "$_";
no need to quote $_
> }
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
|