Perl print Function
This function prints the values of the expressions in LIST to the current default output filehandle, or to the one specified by FILEHANDLE.
If set, the $\ variable will be added to the end of the LIST.
If LIST is empty, the value in $_ is printed instead.
print accepts a list of values and every element of the list will be interpreted as an expression.
Following is the simple syntax for this function −
print FILEHANDLE LIST print LIST print
This function returns 0 on failure and 1 on success.
Following is the example code showing its basic usage −Live Demo
#!/usr/bin/perl -w $string = "That is test"; @list = (1,2,3,4,5,6,); $index = index ($string, 'is'); print "Position of is in the string $index\n"; print "Print list @list\n";
When above code is executed, it produces the following result −
Position of is in the string 5 Print list 1 2 3 4 5 6