{"id":1045,"date":"2011-01-07T08:31:56","date_gmt":"2011-01-07T08:31:56","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=1045"},"modified":"2011-01-07T08:42:35","modified_gmt":"2011-01-07T08:42:35","slug":"perl-interview-qestions","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2011\/01\/perl-interview-qestions\/","title":{"rendered":"Perl Interview Questions?"},"content":{"rendered":"<p><strong>What is use of &#8216;strict&#8217; in perl ?<\/strong><br \/>\nThe module strict restricts &#8216;unsafe constructs&#8217;, according to the perldocs<br \/>\nWhen you enable the strict module, the three things that Perl becomes strict about are:<br \/>\n\u2022 Variables &#8216;vars&#8217;<br \/>\n\u2022 References &#8216;refs&#8217;<br \/>\n\u2022 Subroutines &#8216;subs&#8217;<br \/>\nStrict variables are useful. Essentially, this means that all variables must be declared, that is defined before use. Furthermore, each variable must be defined with my or fully qualified<\/p>\n<p>\n<strong>What is scalars in perl ?<\/strong><br \/>\nThe most basic kind of variable in Perl is the scalar variable. Scalar variables hold both strings and numbers, and are remarkable in that strings and numbers are completely interchangable. For example, the statement<br \/>\n$priority = 9;<br \/>\nsets the scalar variable $priority to 9, but you can also assign a string to exactly the same variable:<br \/>\n$priority = &#8216;high&#8217;<\/p>\n<p>\n<strong>Perl difference between lists and arrays ?<\/strong><br \/>\nA list is a fixed collection of scalars. An array is a variable that holds a variable collection of scalars.<br \/>\nArray operations, which change the scalars, reaaranges them, or adds or subtracts some scalars, only work on arrays. These can\u2019t work on a list, which is fixed. Array operations include shift, unshift, push, pop, and splice.<br \/>\nYou can change an array element, but you can\u2019t change a list element.<\/p>\n<p><\/p>\n<p>What is the use of &#8216;defined&#8217;?<br \/>\n<strong>defined EXPR<br \/>\ndefined <\/strong><\/p>\n<p>Returns true if EXPR has a value other than the undef value, or checks the value of $_ if EXPR is not specified.<br \/>\nIf EXPR is a function or function reference, then it returns true if the function has been defined.<\/p>\n<p>Return Value<br \/>\n\u2022 0 if EXPR contains undef<br \/>\n\u2022 1 if EXPR contains a valid value or reference<\/p>\n<pre lang=\"perl\">\r\n#!\/usr\/bin\/perl\r\n$var1 = \"This is defined\";\r\nif( defined($var1) ){\r\n  print \"$var1\\n\";\r\n}\r\nif( defined($var2) ){\r\n  print \"var2 is also defined\\n\";\r\n}else{\r\n  print \"var2 is not defined\\n\";\r\n}\r\nThis will produce following result\r\nThis is defined\r\nvar2 is not defined\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is use of &#8216;strict&#8217; in perl ? The module strict restricts &#8216;unsafe constructs&#8217;, according to the perldocs When you enable the strict module, the three things that Perl becomes strict about are: \u2022 Variables &#8216;vars&#8217; \u2022 References &#8216;refs&#8217; \u2022 Subroutines &#8216;subs&#8217; Strict variables are useful. Essentially, this means that all variables must be declared, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1045","post","type-post","status-publish","format-standard","hentry","category-ajax"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=1045"}],"version-history":[{"count":2,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1045\/revisions"}],"predecessor-version":[{"id":1047,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/1045\/revisions\/1047"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=1045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=1045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=1045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}