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 symbol is use to represent the hashes in perl? | |
ans: The % symbol is use to represent hashes in perl. | |
Q2.How can we convert a hashes to an array? | |
ans: We can convert a hashes to an array using this syntax: my @var = %hashes. | |
Q3.How can we access item from a hash in perl? | |
ans: We will use sigil $ while accessing the item in hash. syntax: hash | |
Q4.What function is use to check if a key in present in a hash? |
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.Do we need to define the return type of the subroutines in perl? | |
ans: No, we don't need to define the return type in perl. | |
Q2.In which array does the arguements receive by the subroutine are stored? | |
ans: All the arguments recieve by the subroutines is stored in @_ array. | |
Q3.How do we define a default value for an argument in a subroutine? | |
ans: syntax: $var_name ||=value; | |
Q4.What is a state variable ? |
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.How can we find the length of the string ? | |
ans: scalar @array_name will give the length of the array. | |
Q2. What is the use grep function? | |
ans: grep function is use to filter out the array according to condition or expression. | |
Q3.How can we remove a slice of array from an array? | |
ans: we can use splice function to remove a slice of elements from an array. | |
Q4. What is the function of unshift? |
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 last statement in Perl? | |
ans: last statement is use to break out of a running loop. | |
Q2.How can we skip to the next iteration in a loop? | |
ans we can use next statement to skip to the next iteration of a loop. | |
Q3.How many type of loop are there in perl? | |
ans: There are three types :- for loop, while loop and do while loop. | |
Q4.What is the syntax for for loop? |
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 return value if a condition is false? | |
ans: 0 or " ". | |
Q2.What are switch statement called in perl? | |
ans: Given and when statement. | |
Q3.What is the math function to convert a hexadecimal to decimal? | |
ans: Hex function syntax: hex hexadecimal value. | |
Q4.How can we get a random value between 0 and 1? |
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" " ? |
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 are metatable? | |
ans: Metatable are table that are used to modify the behaviour of a table. | |
Q2. How can we attach a metatable for particular table? | |
ans: In lua , we have setmetatable function which will attach a metatables for a table. | |
Q3. How can we use a metamethod defined in the module? | |
ans: we can just use the particular operator to perform the operation of the metamethod define in the metatables. |
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 does a+ mode means in lua? | |
ans: a+ mode is the mode where we can append,read and create a file. | |
Q2. How can we create a file in lua? | |
ans: We can open the file in w+ , if the file doesn't exist it will create a new file. | |
Q3. what does seek() do in lua? | |
ans: seek() function is use to place the filepointer to a specific position. | |
Q4. What does close() function do? |
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 a module in lua | |
ans: A module is like a library full of functions and variables. | |
Q2.How do we create a modules ? | |
ans: It can be created as the same way as we create a tables, but the filename should be same as the module name. | |
Q3.How can we load a module in our lua file? | |
ans: We will require keyword which is used to gain access to the function of the modules. |
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. Do we need to define the return type while defining a function ? | |
ans: No,There is no nedd to define a return type ofr a function in lua. | |
Q2.What is a variadic function in lua? | |
ans: variadic function are those function which accepts unknown number of arguments. | |
Q3.What is anonymous function in lua? | |
Ans: Anonymous function are those function which have body but doesn't have a name. | |
Q4.Does closure have access to all the locak variable in the program? |