Data::...String(3pm)
π Data::Perl::Role::String β the perl manual page, but make it cute π
okay bestie, so this is Data::Perl::Role::String(3pm) β a User Contributed Perl Documentation page, living in your terminal, and ngl it's kind of a little icon. It's a wrapping class for Perl scalar strings. Strings! The moment. The vibe. Let's get into it β¨
β¨ VERSION β¨
version 0.002011 β yes ma'am, that's the number, memorize it π
πΈ SYNOPSIS πΈ
here's the whole entire vibe, copy-paste ready, no cap:
use Data::Perl qw/string/;
my $string = string("foo\n");
$string->chomp; # returns 1, $string == "foo"
see that? you make a string, you chomp it, it becomes "foo", it hands you back a 1. chef's kiss. π
π¦ DESCRIPTION π¦
So basically, this class is your whole wrapper-and-methods situation for interacting with scalar strings. That's it. That's the job. She wraps, she provides methods, she serves. π
π PROVIDED METHODS π
Every single one, listed, because we do not skip. Not here. Not ever.
new($value)β Constructs a brand newData::Perl::Stringobject and returns it. If you pass in$value, she's initialized with it. If you don't, she's just out here existing. Your call, bestie π«Άincβ Increments the value stored in this slot using the magical string autoincrement operator. β οΈ Important tea: Perl doesn't provide analogous behavior in"--", sodecis not available. Don't go looking for her, she's not coming. Returns the new value.
This method does not accept any arguments. Zero. None. π
append($string)β Appends to the string, like.=, and returns the new value.
This method requires a single argument.
prepend($string)β Prepends to the string and returns the new value.
This method requires a single argument.
replace($pattern, $replacement)β Performs a regexp substitution (that's"s"in perlop, iykyk). π¨ Heads up: there is no way to provide the"g"flag. Instead, code references will be accepted for the replacement, and that causes the regex to be modified with a single"e". Also,"/smxi"can be applied using the"qr"operator. Returns the new value.
This method requires two arguments.
match($pattern)β Runs the regex against the string and returns the matching value(s). Slay π
This method requires a single argument.
chopβ Just like"chop"in perlfunc. Returns the chopped character.
This method does not accept any arguments.
chompβ Just like"chomp"in perlfunc. Returns the number of characters removed.
This method does not accept any arguments.
clearβ Sets the string to the empty string. π’ And like β specifically the empty string, not the value passed to"default". Read that again. Not the default. The empty one.
This method does not have a defined return value.
This method does not accept any arguments.
lengthβ Just like"length"in perlfunc, returns the length of the string. Short king behavior, measuring things. πsubstrβ This acts just like"substr"in perlfunc. And when you call it as a writer, it returns the substring that was replaced, just like the Perl builtin does. Consistent! Iconic!
This method requires at least one argument, and accepts no more than three.
π₯ SEE ALSO π₯
go read these too, they're the friends of the family:
Data::PerlMooX::HandlesVia
π AUTHOR π
Matthew Phillips <mattp@cpan.org> β thank you for your service π«‘
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2020 by Matthew Phillips <mattp@cpan.org>.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie, every last crumb of it π this little doc came to you from perl v5.36.0, dated 2022-10-16, and honestly? she ate. periodt. πΈβ¨π
π¦ where this page comes from
- ubuntu noble: libdata-perl-perl 0.002011-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-perl-perl 0.002011-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-perl-perl 0.002011-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms