The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Hydrogen::String - a standard library for strings

VERSION

This documentation is for Hydrogen::String 0.018, which is based on Sub::HandlesVia::HandlerLibrary::String 0.046.

FUNCTIONS

Each function expects a string scalar as its first argument.

append( $string, $tail )

Additional arguments: Str.

Appends another string to the end of the current string and updates the original value.

chomp( $string )

Like chomp from perlfunc.

chop( $string )

Like chop from perlfunc.

clear( $string )

Sets the string to the empty string.

cmp( $string, $str )

Additional arguments: Str.

Returns $string cmp $str.

cmpi( $string, $str )

Additional arguments: Str.

Returns fc($string) cmp fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

contains( $string, $str )

Additional arguments: Str.

Returns true iff the string contains $str.

contains_i( $string, $str )

Additional arguments: Str.

Returns true iff the string contains $str case-insensitvely.

ends_with( $string, $tail )

Additional arguments: Str.

Returns true iff the string ends with $tail.

ends_with_i( $string, $tail )

Additional arguments: Str.

Returns true iff the string ends with $tail case-insensitvely.

eq( $string, $str )

Additional arguments: Str.

Returns $string eq $str.

eqi( $string, $str )

Additional arguments: Str.

Returns fc($string) eq fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

fc( $string )

Returns fc($string).

ge( $string, $str )

Additional arguments: Str.

Returns $string ge $str.

gei( $string, $str )

Additional arguments: Str.

Returns fc($string) ge fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

get( $string )

Gets the current value of the string.

gt( $string, $str )

Additional arguments: Str.

Returns $string gt $str.

gti( $string, $str )

Additional arguments: Str.

Returns fc($string) gt fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

inc( $string )

Performs ++ on the string.

lc( $string )

Returns lc($string).

le( $string, $str )

Additional arguments: Str.

Returns $string le $str.

lei( $string, $str )

Additional arguments: Str.

Returns fc($string) le fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

length( $string )

Like length from perlfunc.

lt( $string, $str )

Additional arguments: Str.

Returns $string lt $str.

lti( $string, $str )

Additional arguments: Str.

Returns fc($string) lt fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

match( $string, $regexp )

Additional arguments: Str|RegexpRef.

Returns true iff the string matches the regexp.

match_i( $string, $regexp )

Additional arguments: Str|RegexpRef.

Returns true iff the string matches the regexp case-insensitively.

ne( $string, $str )

Additional arguments: Str.

Returns $string ne $str.

nei( $string, $str )

Additional arguments: Str.

Returns fc($string) ne fc($str). Uses lc instead of fc in versions of Perl older than 5.16.

prepend( $string, $head )

Additional arguments: Str.

Prepends another string to the start of the current string and updates the original value.

replace( $string, $regexp, $replacement )

Additional arguments: Str|RegexpRef, Str|CodeRef.

Replaces the first regexp match within the string with the replacement string.

replace_globally( $string, $regexp, $replacement )

Additional arguments: Str|RegexpRef, Str|CodeRef.

Replaces the all regexp matches within the string with the replacement string.

reset( $string )

Resets the original value to its default value, or an empty string if it has no default.

set( $string, $value )

Additional arguments: Str.

Sets the string to a new value.

starts_with( $string, $head )

Additional arguments: Str.

Returns true iff the string starts with $head.

starts_with_i( $string, $head )

Additional arguments: Str.

Returns true iff the string starts with $head case-insensitvely.

substr( $string, $start, $length?, $replacement? )

Additional arguments: Int, Optional[Int], Optional[Str].

Like substr from perlfunc, but is not an lvalue.

uc( $string )

Returns uc($string).

EXPORT

No functions are exported by this module by default. To import them all (this is usually a bad idea), use:

    use Hydrogen::String -all;

To import a particular function, use:

    use Hydrogen::String 'chop';

To rename functions:

    use Hydrogen::String 'chop' => { -as => 'myfunc' };

On Perl 5.37.2+, you can import lexically:

    use Hydrogen::String -lexical, 'chop';

See Exporter::Tiny::Manual::Importing for more hints on importing.

BUGS

Please report any bugs to http://github.com/tobyink/p5-hydrogen/issues.

SEE ALSO

Hydrogen, Hydrogen::Curry::String, Hydrogen::Topic::String, Sub::HandlesVia::HandlerLibrary::String.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2022 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.