Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: cleaning up control characters

by monkfish (Pilgrim)
on Oct 27, 2001 at 00:52 UTC ( #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? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-01-27 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?