Clownf...:String(3pm)
β¨ NAME β¨
Clownfish::String β the immaculate, untouchable, never-changing string that holds Unicode characters. π
It's giving immutable. Like, you literally cannot change her. Periodt.
πΈ SYNOPSIS πΈ
my $string = Clownfish::String->new('abc');
print $string->to_perl, "\n";
π¦ DESCRIPTION π¦
okay bestie, no preamble, we're going straight to the good stuff π«Ά
π CONSTRUCTORS π
new
my $string = Clownfish::String->new($perl_string);
Hand her a Perl string, get a String back that's holding it. That's it. That's the whole vibe check. β¨
π METHODS π
cat
my $result = $string->cat($other);
Glues the String and other together and returns the result. The two of them, combined, iconic. π₯
to_i64
my $int = $string->to_i64();
Pulls a 64-bit integer out of a decimal string. The deets live in basex_to_i64() β go look there. π
basex_to_i64
my $int = $string->basex_to_i64($base);
Extracts a 64-bit integer from a variable-base stringified version. She expects an optional minus sign followed by base-x digits, and she stops dead at any non-digit character. If no digits are found at all, you get zero. π
Careful bestie: if the value goes past the range of an int64_t, the result is undefined. Not "wrong", not "clamped" β undefined. Do not test her. π
baseβ a base between 2 and 36.
to_f64
my $float = $string->to_f64();
Turns a string into a floating-point number, using the C library function strtod. Classic. π
starts_with
my $bool = $string->starts_with($prefix);
Checks whether the String starts with prefix. Yes or no, no in-between. π
ends_with
my $bool = $string->ends_with($suffix);
Checks whether the String ends with suffix. π
contains
my $bool = $string->contains($substring);
Checks whether the String contains substring. Somewhere. Anywhere. π¦
find
my $string_iterator = $string->find($substring);
Returns a StringIterator pointing at the first occurrence of substring inside the String, or undef if the substring doesn't match anything. No match, no iterator, no drama. β¨
length
my $int = $string->length();
The number of Unicode code points the String contains. Code points, not bytes β she's counting the real ones. π
get_size
my $int = $string->get_size();
The number of bytes occupied by the String's internal content. Different number, different question, don't mix them up. π
to_bytebuf
my $byte_buf = $string->to_bytebuf();
Returns a ByteBuf holding a copy of the String. A whole new container, same contents. π«Ά
clone
my $result = $string->clone();
Returns a clone of the object. A twin. A copy. Main character energy, duplicated. π
compare_to
my $int = $string->compare_to($other);
Tells you whether one String is less than, equal to, or greater than another. The Unicode code points get compared lexicographically. And if other is not a String? She throws an exception. Do not come to her with the wrong type. π
Returns: 0 if the Strings are equal, a negative number if self is less than other, and a positive number if self is greater than other.
trim
my $result = $string->trim();
Returns a copy of the String with Unicode whitespace characters removed from both top and tail. "Whitespace" here means any character that has the Unicode property White_Space. Glow-up, both ends. β¨
trim_top
my $result = $string->trim_top();
Returns a copy of the String with the leading Unicode whitespace removed. Whitespace is any character that has the Unicode property White_Space. π
trim_tail
my $result = $string->trim_tail();
Returns a copy of the String with the trailing Unicode whitespace removed. Whitespace is any character that has the Unicode property White_Space. π¦
code_point_at
my $int = $string->code_point_at($tick);
Returns the Unicode code point located tick code points in from the top. If you're out of bounds, you get CFISH_STR_OOB. That's the boundary, bestie. π§
code_point_from
my $int = $string->code_point_from($tick);
Returns the Unicode code point located tick code points counting backwards from the end. Out of bounds? CFISH_STR_OOB. Same rules, opposite direction. π
substring
my $result = $string->substring(
offset => $offset, # required
length => $length, # required
);
Returns a new substring containing a copy of the specified range.
offsetβ offset from the top, in code points.lengthβ the desired length of the substring, in code points.
Both required. She's not guessing what you meant. πΈ
top
my $string_iterator = $string->top();
Returns an iterator initialized to the start of the string. Fresh from the top, as the name says. β
tail
my $string_iterator = $string->tail();
Returns an iterator initialized to the end of the string. Right at the tail end. π
π INHERITANCE π
Clownfish::String isa Clownfish::Obj. Family tree, established. π§
that's the whole page bestie, every flag and every method accounted for, no cap π this was the Clownf...:String(3pm) page from the User Contributed Perl Documentation, version perl v5.42.3, dated 2026-09-02 β slay, go write some strings πβ¨π
π¦ where this page comes from
- fedora 43: perl-Clownfish 0.8.0-1.fc43 Β· Apache-2.0
- fedora 44: perl-Clownfish 0.8.0-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms