Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Control characters

by tbone1 (Monsignor)
on Jun 05, 2009 at 15:18 UTC ( #768820=note: print w/ replies, xml ) Need Help??


in reply to Control characters

I was going to suggest using regular expressions and the s/// command but the control characters make it rather tricky, since the ^ anchors a search at the beginning of a string. Quick and dirty, but maybe something like this?

s/(.)?^O/\1/g; s/(.)?^N/\1/g;

--
tbone1, YAPS (Yet Another Perl Schlub)
And remember, if he succeeds, so what.
- Chick McGee


Comment on Re: Control characters
Replies are listed 'Best First'.
Re^2: Control characters
by AnomalousMonk (Abbot) on Jun 05, 2009 at 16:55 UTC
    s/(.)?^O/\1/g; s/(.)?^N/\1/g;
    But what do these statements really do?
    >perl -wMstrict -le "for my $str (@ARGV) { printf q{%s -> }, $str; $str =~ s/(.)?^O/\1/g; $str =~ s/(.)?^N/\1/g; print $str; } " OhNoOhNo NotOnNotOn \1 better written as $1 at -e line 1. \1 better written as $1 at -e line 1. Use of uninitialized value $1 in substitution iterator at -e line 1. OhNoOhNo -> hNoOhNo Use of uninitialized value $1 in substitution iterator at -e line 1. NotOnNotOn -> otOnNotOn

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-30 05:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls