getc() function in Perl is used to read the next character from the file whose File Handle is passed to it as argument. If no FileHandle is passed then it takes one character as input from the user.
Syntax: getc(FileHandle)
Parameter:
FileHandle: of the file to be read
Returns: the character read from the file or undef on end of file
Example 1:
open (fh, "<" , "File_to_be_read.txt" );
$ch = getc (fh)
print "Character read from the file is $ch" ;
close (fh);
|
Output:
Example 2:
$ch = getc (STDIN);
print "Value entered: $ch" ;
|
Output:
Last Updated :
07 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...