in reply to Can't get \n or other character/translation escapes to interpolate if originally read from a data file
Here's something you can do to get the string in the format I think you want: the String::Interpolate module allows you to pass a string with character escapes and get back the string that I believe you desire.
yieldsC:\usr\local\share>perl use strict; use warnings; use v5.10; use String::Interpolate qw/interpolate/; my @lines = <DATA>; for my $line ( @lines ) { chomp $line; say "data line is *$line*"; my $real = interpolate($line); say "real line is *$real*"; } __DATA__ hello\ngoodbye good\nevil yes\nno
data line is *hello\ngoodbye* real line is *hello goodbye* data line is *good\nevil* real line is *good evil* data line is *yes\nno* real line is *yes no*
note: I've never used it before today; I found it via a quick search, and its description and above behavior seemed right.
Also, I don't have the Programming Perl to check page numbers, but "translation escapes" sound like escapes that are only available to the regex substitution engine and not to normal strings, so those will likely not be available even in String::Interpolate (unchecked).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can't get \n or other character/translation escapes to interpolate if originally read from a data file
by haukex (Archbishop) on Mar 15, 2021 at 17:35 UTC | |
by pryrt (Abbot) on Mar 15, 2021 at 19:06 UTC | |
by haukex (Archbishop) on Mar 15, 2021 at 19:12 UTC | |
|
Re^2: Can't get \n or other character/translation escapes to interpolate if originally read from a data file (updated)
by AnomalousMonk (Archbishop) on Mar 15, 2021 at 17:53 UTC | |
by pryrt (Abbot) on Mar 15, 2021 at 19:02 UTC |