Copyright © tutorialspoint.com

PERL print Function


Syntax

print FILEHANDLE LIST

print LIST

print


Definition and Usage

  • 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.

Return Value

  • 0 on failure

  • 1 on success

Example

Try out following example:

#!/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";

It will produce following results:

Position of is in the string 5
Print list 1 2 3 4 5 6

Copyright © tutorialspoint.com