Common Perl string functions

Source: Internet
Author: User
Tags uppercase letter

1. $ position =Index(String, substring, skipchars );

This function returns the position of the substring in the string. If the substring does not exist,-1 is returned. The skipchars parameter is an optional parameter, indicating the number of characters that have been skipped. That is: search from this location;

2,Rindex(String, substring, skipchars): The function is similar to index (). The difference is that it starts searching from the right end of string;

3. $ Len =Length(String): Evaluate the length of a string;

4. $ offset =Pos(String): returns the position of the last pattern match;

5. $ substring =Substr(String, skipchars, length): This function skips the position of skipchars characters in the string (from the position of skipchars) and extracts the child string whose length is length; the position of the first character is 0; length can be omitted.

6,Study(String): increases the access speed of variables in an internal format, and only applies to one variable at a time;

7,LC(String): converts all letters in string to lowercase letters;

8,UC(String): converts all letters in string to uppercase letters;

9,Lcfirst(String): converts the first letter in the string to a lower-case letter;

10,Ucfirst(String): converts the first letter in the string to a uppercase letter;

11,Join(Sepatorstring, list): concatenates all elements in the list to the same string, and uses sepatorstring to separate two adjacent elements;

12,Sprintf(Formatstring, field1, field2 ,..., fieldn): this function is used in the same way as the sprintf () function in C language. It is used to format multiple strings. The difference is that the function returns the formatted result string;

13,Quotemeta(String): Add a backslash (/) to the front of a non-word in string "/";

14,HEX(String): converts hexadecimal data in the string format to a decimal integer;

15,Int(Floatnum): removes the fractional part of the floating point number and converts it to an integer;

16,Oct(Ocunum): converts string-type octal (0) or hexadecimal (0x) data to a decimal number;

17,ORD(Char): returns the ASCII value (integer) of the character char );

18,CHR(Ascii_value): returns the character corresponding to the integer ascii_value; 0 <= ascii_value <= 255;

19,Defined(Expr): determines whether an element in a variable, array, or array has been assigned a value. expr is a variable name, array name, or an array element. If it has been defined or assigned a value, true is returned; otherwise, false is returned;

20,UNDEF(Expr): cancels the definition of variables, arrays, or elements in an array, or even cancels the definition of subprograms, and reclaim the space occupied by them. The returned value is always an undefined value. This value is equivalent to an empty string, for example, $ retvalue = UNDEF (expr );

Common Perl string functions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.