The getc function gets a single character from the keyboard or from a file. : getc « File « Perl






The getc function gets a single character from the keyboard or from a file.

    

At EOF, getc returns a null string.

getc(FILEHANDLE)
getc FILEHANDLE
getc


# Getting only one character of input 

print "Answer y or n   ";
$answer=getc;     # Gets one character from stdin
$restofit=<>;     # What remains in the input buffer is assigned to $restofit
print "$answer\n";
print "The characters left in the input buffer were: $restofit\n";

   
    
    
    
  








Related examples in the same category

1.Using getc function to read character from a file
2.Using getc function with while loop
3.Using getc.