Perl | getc Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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: Perl #!/usr/bin/perl # Opening a File in Read-only mode open(fh, "<", "File_to_be_read.txt"); # Reading next character from the file $ch = getc(fh) # Printing the read character print"Character read from the file is $ch"; # Closing the File close(fh); Output: Example 2: Perl #!/usr/bin/perl # Value to be entered by the user $ch = getc(STDIN); # Printing the entered value print"Value entered: $ch"; Output: Comment More infoAdvertise with us Next Article Perl | ord() Function C Code_Mech Follow Improve Article Tags : Perl Perl-files Perl-function Perl-File-Functions Similar Reads Perl | int() function int() function in Perl returns the integer part of given value. It returns $_ if no value provided. Note that $_ is default input which is 0 in this case. The int() function does not do rounding. For rounding up a value to an integer, sprintf is used. Syntax: int(VAR) Parameters: VAR: value which is 1 min read Perl | oct() Function oct() function in Perl converts the octal value passed to its respective decimal value. For example, oct('1015') will return '525'. This function returns the resultant decimal value in the form of a string which can be used as a number because Perl automatically converts a string to a number in nume 1 min read Perl | length() Function length() function in Perl finds length (number of characters) of a given string, or $_ if not specified. Syntax:length(VAR) Parameter: VAR: String or a group of strings whose length is to be calculated Return: Returns the size of the string. Example 1: Perl #!/usr/bin/perl # String whose length is t 1 min read Perl | ord() Function The ord() function is an inbuilt function in Perl that returns the ASCII value of the first character of a string. This function takes a character string as a parameter and returns the ASCII value of the first character of this string. Syntax: ord string Parameter: This function accepts a single par 1 min read Perl | uc() Function uc() function in Perl returns the string passed to it after converting it into uppercase. It is similar to ucfirst() function which returns only first character in uppercase. Note: The characters which are already in UpperCase are not modified. Syntax: uc String Returns: string in uppercase. Example 1 min read Perl | cos() Function This function is used to calculate cosine of a VALUE or $_ if VALUE is omitted. The VALUE should be expressed in radians. Syntax: cos(VALUE) Parameters: VALUE in the form of radians Returns: Function returns cosine of VALUE. Example 1: Perl #!/usr/bin/perl # Calling cos function $var = cos(5); # Pri 1 min read Like