Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: cleaning up control characters

by monkfish (Pilgrim)
on Oct 27, 2001 at 00:52 UTC ( [id://121695]=note: print w/replies, xml ) Need Help??


in reply to cleaning up control characters

I just changed your regular expression to match 0 to 2 control chars and replace them with nothing otherwise I did not touch the code.
[:cntrl:] is the key to matching any control chars.

#!/usr/bin/perl -w use strict; my ($infile, $outfile, $line); $infile = "c:/perldev/restore.txt"; $outfile = "c:/perldev/fixed_restore.txt"; open (INFILE, $infile) || die "Can't open $infile! $!"; open (OUTFILE, ">$outfile) || die "Can't open $outfile! $!"; while (<INFILE>) { $line = $_; $line =~ s/^[:cntrl:]{0,2}//; print OUTFILE $line; } close (INFILE); close (OUTFILE);
-monkfish (the fishy monk)

Edit fixed error with \C[

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://121695]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-23 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found