Created
December 6, 2021 06:33
-
-
Save rozer007/65d3288a00a9c550abae0d8c0c8a0819 to your computer and use it in GitHub Desktop.
Introduction to 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 comment in perl ? | |
ans: syntax : =begin .....comments .....=end =cut | |
Q2. is there a integer data type in perl ? | |
ans: No , perl have three data types : scalar,array and hashes. | |
Q3. How do we access a scalar variable in perl? | |
ans: We use sigil ($) before every scalar variable while accessing. | |
Q4. what is difference while print' ' and print" " ? | |
ans: Only double quotes "interpolate" variables and special characters such as newlines (\n). | |
Whereas single quotes will print the variable and special character literally. |
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 will be the output of this statement : | |
print 'Hello \n world'; | |
a) Hello | |
world | |
b) Error | |
c) Hello world | |
d) Hello \n world | |
ans: d) | |
Q2.What will be the output of this statement : | |
printf("%.2f",12.222223); | |
a)12.23 | |
b)12.222 | |
c)12.22 | |
d) 12.222223 | |
ans: c) | |
Q3.Output of this code : | |
my $bigint = 18446744073709551615; | |
printf("%d\n",$bigint+1); | |
printf("%u",$bigint+1); | |
a) 18446744073709551615 | |
18446744073709551615 | |
b) 18446744073709551616 | |
18446744073709551615 | |
c) -1 | |
18446744073709551615 | |
d) 18446744073709551616 | |
18446744073709551616 | |
ans : c) | |
Q4.Is the below statement correct way to swap three variable ? | |
my $a=10,$b=11,$c=12; | |
($a,$b,$c)={$b,$c,$a}; | |
a) true | |
b) false | |
ans: b) | |
Q5. my $a=<STDIN>; | |
print $a; | |
print $a; | |
what will be the output if the input is "pep": | |
a) peppep | |
b) pep | |
pep | |
c) pep pep | |
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