Created
December 6, 2021 11:08
-
-
Save rozer007/717c1f0103dbbe3f68a18c8bf48dfc60 to your computer and use it in GitHub Desktop.
Strings in perl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1. What is the syntax for multiline strings? | |
ans: syntax: <<END; | |
....... | |
....... | |
END | |
Q2.What is the syntax of Substitution operator ( s ): | |
ans: syntax : s/word/pattern/; | |
Q3.What operation does rindex function perform? | |
ans: This function will give the rear/last index of the specific character or a string. | |
Q4.How can we concatenate two strings in perl? | |
ans: We should use . dot operator to concatenate two string. | |
Q5.What does ufirst function do? | |
ans: ufirst function will convert the first character of a string to uppercase letter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Q1.Q1.What will be the ouput of the statement: | |
print "Hello world " x 3 ,"\n"; | |
a) Hello world | |
Hello world | |
Hello world | |
b) Hello world | |
c) Hello world Hello world Hello world | |
d) none of the above | |
Q2.What will be the output: | |
my $str = "Hello Pepcoderss"; | |
for(my $i = 0; $i <3; $i++) | |
{ | |
chop $str; | |
} | |
print $str; | |
a) Hello pepcoder | |
b) lo pepcoderss | |
c) Hello pepcode | |
d) lo pepcode | |
ans: c) | |
Q3.What will be the output of the statement: | |
my $str="hello Hello heLlo HELLO"; | |
$str=~ s/hello/bye/; | |
print $str; | |
a) bye bye bye bye | |
b) bye bye heLlo HELLO | |
c) bye Hello heLlo HELLO | |
d) bye Hello heLlo bye | |
ans: c) | |
Q4.What will be the output of the statement: | |
my $str="helo"; | |
print ++$str; | |
a) ielo | |
b) ifmp | |
c) help | |
d) ielp | |
ans: c) | |
Q5.What will be the output of this statement: | |
my $str="hellp pepcoder"; | |
print substr($str, 2,3); | |
a) l | |
b) llp | |
c) ll | |
d) none of the above | |
ans: b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment