in reply to Re: Can't get \n or other character/translation escapes to interpolate if originally read from a data file
in thread Can't get \n or other character/translation escapes to interpolate if originally read from a data file
So, to be able to search for this 2-line string in a document that uses Unix-type line endings:
Reach Holly Smith for help by sending an email To hollysmith@nosuchdomain.com.
.... the character-specific way to do it (rather than using \n) would have been to store the “old string”~“new string” line in a __DATA__ block, like this, using the Unix-type newline character (code point 10, or 0A in hexadecimal):
__DATA__
Reach Holly Smith for help by sending an email\x{0A}to hollysmith@nosuchdomain.com.~For more information, contact Holly Smith.
...where the preceding line is a single line even though it almost certainly will wrap on this web page; is that what you mean?
I think I’m coming to see the point of being able to use \n in a regular expression — it avoids the need to specify what the characters are that represent a new line in the operating system being used to write and read the file, and it’s a memorable way to avoid having to look up the code point for those characters. Plus a manual entry of a new line at the keyboard while creating a line-by-line data file would gunk up the use of
while ( <DATA> )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Can't get \n or other character/translation escapes to interpolate if originally read from a data file
by AnomalousMonk (Archbishop) on Mar 16, 2021 at 21:58 UTC | |
|
Re^3: Can't get \n or other character/translation escapes to interpolate if originally read from a data file
by LanX (Saint) on Mar 16, 2021 at 13:03 UTC |