Perl | values() Function Last Updated : 07 May, 2019 Comments Improve Suggest changes Like Article Like Report 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 context and number of values in the scalar context Example 1: Perl #!/usr/bin/perl -w # Hash containing Keys and values %sample_hash = ('Geeks' => 'A', 'for' => 'B', 'Geek' => 10, 'World' => 20); # values() in list context returns # values stored in the sample_hash @values = values(%sample_hash); print("Values in the Hash are: ", join("-", @values), "\n"); # values() in scalar context returns # the number of values stored in sample_hash $values = values( %sample_hash); print "Number of values in Hash are: $values"; Output: Values in the Hash are A-B-10-20 Number of values in Hash are: 4 Example 2: Perl #!/usr/bin/perl -w # Hash containing Keys and values %sample_hash = (1 => 'Welcome', 2 => 'to', 3 => 'Geeks', 4 => 'World'); # values() in list context returns # values stored in the sample_hash @values = values( %sample_hash); print("Values in the Hash are ", join("-", @values), "\n"); # values() in scalar context returns # the number of values stored in sample_hash $values = values(%sample_hash); print "Number of values in Hash are: $values"; Output: Values in the Hash are Welcome-World-to-Geeks Number of values in Hash are: 4 Comment More infoAdvertise with us Next Article Perl | values() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function Perl-Hash-Functions Similar Reads Perl | reset() Function reset() function in Perl resets (clears) all package variables starting with the letter range specified by value passed to it. Generally it is used only within a continue block or at the end of a loop. Note: Use of reset() function is limited to variables which are not defined using my() function. S 2 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 | 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 | split() Function split() is a string function in Perl which is used to split or you can say to cut a string into smaller sections or pieces. There are different criteria to split a string, like on a single character, a regular expression(pattern), a group of characters or on undefined value etc.. The best thing abou 8 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 | 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 | abs() function This function returns the absolute value of its argument. If a pure integer value is passed then it will return it as it is, but if a string is passed then it will return zero. If VALUE is omitted then it uses $_ Syntax: abs(VALUE) Parameter: VALUE: It is a required number which can be either positi 2 min read Perl | Useful Hash functions A hash is a set of key-value pairs. Perl stores elements of a hash such that it searches for the values based on its keys. Perl provides various functions to perform operations on Hashes, such as to return values of the hash, to delete elements from a hash, etc. Example: Perl #!/usr/bin/perl # Initi 2 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 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 Like