O'Reilly logo

Perl Pocket Reference, 5th Edition by Johan Vromans

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

String Functions

chomp list

Removes $/ (page 70) from all elements of the list; returns the (total) number of characters removed.

chop list

Chops off the last character on all elements of the list; returns the last chopped character.

crypt plaintext, salt

Encrypts a string (irreversibly).

eval expr

Parses and executes expr as if it were a Perl program. The value returned is the value of the last expression evaluated. If there is a syntax error or runtime error, undef is returned by eval, and $@ is set to the error message. See also eval in page 63.

index str, substr [ , offset ]

Returns the position of substr in str at or after offset. If the substring is not found, returns –1.

lc expr

Returns a lowercase version of expr. See also \L in page 7.

lcfirst expr

Returns expr with its first character in lowercase. See also \l in page 7.

length expr

Returns the length in characters of expr.

quotemeta expr

Returns expr with all regular expression metacharacters quoted. See also \Q in page 7.

rindex str, substr [ , offset ]

Returns the position of the last substr in str at or before offset. If the substring is not found, returns –1.

substr expr, offset [ , len [ , newtext ] ]

Extracts a substring of length len starting at offset out of expr and returns it. If offset is negative, counts from the end of the string. If len is negative, leaves that many characters off the end of the string. Replaces the substring with newtext if specified, otherwise, may be assigned to.

uc expr

Returns an uppercase version ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required