Program Code:
#! /Perl/bin/perl
$var=1234;
$var="This is the number with value $var \n";
print($var);
$var=12;
print("This is a number with value $var \n");
# \L is used to convert the letters to lower case and \E is used to disable the effect of \L
$var = "T\LHIS IS A \ESTRING \n"; # same as "This is a STRING"
print($var);
#If you want to print the $ or " or \ use escape character \ to print all this
$var=12;
print("This is a number with value of \$var is $var \n");
# ascii value of any character in octal using /nnn notation where nnn is an octal number
$var="\120";
print($var);
print("\n");
# ascii value of any character in hexadecimal using /xnn notation where nnn is an octal number
$var="\x56";
print($var);
Output:
Program Code:
#! /Perl/bin/perl
print("Enter a line \n ");
$input=<STDIN>;
print("UpperCase: \U$input\n");
print("LowerCase: \L$input\n");
#\u forces to print first letter in capital letter
print("A sentence: \L\u$input\n");
$text = 'This string contains \', a quote character';
print($text,"\n");
$text = 'This is two lines of text';
print($text);
0 comments:
Post a Comment