We can get the character representation of a number by using the chr()
method in Perl.
chr(number)
number
: This is the number that we want to get the string representation for.
number
: The value returned is the string representation of the number value.
# create number variables# and initialize$no1 = 65;$no2 = 66;$no3 = 100;$no4 = 200;# get character representations$ch1 = chr($no1);$ch2 = chr($no2);$ch3 = chr($no3);$ch4 = chr($no4);# print resultsprint "$ch1\n";print "$ch2\n";print "$ch3\n";print $ch4;
chr()
method on the number values we create. We store the results in the variables $ch1
, $ch2
, $ch3
, amd $ch4
.