Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interpolating a variable into an escape sequence

Status
Not open for further replies.

bbv4464

Technical User
Jan 30, 2010
2
US
Is it possible to interpolate the contents of a variable into an escape sequence?

Something like
Code:
# print LINEFEED, FORMFEED, and CARRIAGE RETURN
print "\c$_" foreach ('J', 'L', 'M');

I have tried:
Code:
my $x = "L";
print "\c$x";

my $x = "L";
print eval "\c$x";

my $x = '\c';
my $y = 'L';
print "$x$y";

my $x = '\c';
my $y = 'L';
print eval "$x$y";

my $x = '\c';
my $y = 'L';
my $z = $x$y;
$z =~ s/(\$\w+)/$1/eeg; # from perl faq4
print $z;
and none work the way I expected (that is not at all).
Is there a way to do this in perl?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top