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 new Data::Perl::String object 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 "--", so dec is 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::Perl
  • MooX::HandlesVia

πŸ’œ AUTHOR πŸ’œ

Matthew Phillips <mattp@cpan.org> β€” thank you for your service 🫑


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