Perl | tell() Function Last Updated : 07 May, 2019 Comments Improve Suggest changes Like Article Like Report tell() function in Perl is used to get the position of the read pointer in a File with the use of its FileHandle. If no FileHandle is passed then it returns the position within the most recent accessed file. Syntax: tell(FileHandle) Parameter: FileHandle: Filehandle of the file to be accessed. Returns: the current position of the read pointer Example 1: Perl #!/usr/bin/perl # Opening a File in Read-only mode open(fh, "<", "Hello.txt"); $position = tell(fh); print("Position of read pointer before reading: $position"); # Reading first 10 characters from the file for($i = 0; $i < 10; $i++) { $ch = getc(fh); } $position = tell(fh); # Current position of the read pointer print("\nCurrent Position: $position"); # Closing the File close(fh); Output: Example 2: Perl #!/usr/bin/perl # Opening a File in Read-only mode open(fh, "<", "Hello.txt"); $position = tell(fh); print("Position of read pointer before reading: $position\n"); # Printing First 10 Characters print("First ten characters are: "); # Reading and printing first # 10 characters from the file for($i = 0; $i < 10; $i++) { $ch = getc(fh); print" $ch"; } $position = tell(fh); # Current position of the read pointer print("\nCurrent Position: $position"); # Closing the File close(fh); Output: Comment More infoAdvertise with us Next Article Perl | tell() Function C Code_Mech Follow Improve Article Tags : Perl Perl-files Perl-function Perl-File-Functions Similar Reads Perl | sqrt() Function Many times it happens that while solving mathematical expressions we require to calculate the square root of a number. To solve this issue, like other programming language Perl provides us with a built-in function sqrt() which can be used to calculate the square root of a number. Syntax: sqrt value 1 min read Perl | sleep() Function sleep() function in Perl is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds or forever if parameter is not specified. The sleep( ) function accepts seconds as a parameter and returns the same on success. Syntax: sleep(seconds) Returns: 1 min read Perl | sin() Function This function is used to calculate sine of a VALUE or $_ if VALUE is omitted. This function always returns a floating point. Syntax: sin(VALUE) Parameters: VALUE in the form of float Returns: Function returns sine of VALUE. Example 1: Perl #!/usr/bin/perl # Calling sin() function $var = sin(5); # Pr 1 min read Perl | return() Function return() function in Perl returns Value at the end of a subroutine, block, or do function. Returned value might be scalar, array, or a hash according to the selected context. Syntax: return Value Returns: a List in Scalar Context Note: If no value is passed to the return function then it returns an 2 min read Perl | values() Function values() Function in Perl returns the list of all the values stored in a Hash. In a scalar context it returns the number of elements stored in the Hash. Note: Values returned from the value() Function may not always be in the same order. Syntax: values Hash Returns: list of values in the list contex 2 min read Perl | substr() function substr() in Perl returns a substring out of the string passed to the function starting from a given index up to the length specified. This function by default returns the remaining part of the string starting from the given index if the length is not specified. A replacement string can also be passe 2 min read Perl | rindex() Function rindex() function in Perl operates similar to index() function, except it returns the position of the last occurrence of the substring (or pattern) in the string (or text). If the position is specified, returns the last occurrence at or before that position. Syntax: # Searches pat in text from given 2 min read Perl | prototype() Function prototype() function in Perl returns a string containing the prototype of the function or reference passed to it as an argument, or undef if the function has no prototype. Syntax: prototype(function_name) Parameter: function_name: Function whose prototype is to be determined Returns: prototype of th 1 min read Perl | sprintf() Function sprintf() function in Perl uses Format provided by the user to return the formatted string with the use of the values in the list. This function is identical to printf but it returns the formatted string instead of printing it. Syntax: sprintf Format, List Returns: a formatted scalar string Example 1 min read Perl | srand() Function The srand() function in Perl helps rand() function to generate a constant value each time the program is run. This srand() function uses the same parameter each time the rand() function is called for getting constant random value. Syntax: srand(seed) Parameters: seed : It is an integer value. Return 3 min read Like