We don't bite newbies here... much | |
PerlMonks |
Interpretting character combinations as special characters.by music_man1352000 (Novice) |
on Dec 10, 2009 at 12:52 UTC ( [id://812171]=perlquestion: print w/replies, xml ) | Need Help?? |
music_man1352000 has asked for the wisdom of the Perl Monks concerning the following question:
Hi all. Here is a tricky little problem for you! I am writing a script that reads in some textual content in which special characters (newline, tab etc.) have been converted to their string representations. For example, all newline characters in the input have been converted to "\n" (the string literal; literally '\' then 'n'). The input also contains escape sequences such as "\(" and "\)" (parentheses were meta characters in the context where the input content was produced). My script needs to convert the special character sequences back into the original special characters (ie. "\n" needs to be interpretted as the newline character again) and un-escape the meta characters as well. My question is how do I do this? I have tried a couple of approaches:
I would prefer the solution to be general so I don't have to do a regex for each special character (newline, tab etc.) and meta character. Thanks in advance...
Back to
Seekers of Perl Wisdom
|
|