Data::Perl::Role::String(3pm)

Data::Perl::Role::String3pm

Wrapping class for perl scalar strings.

Usage

  use Data::Perl qw/string/;
  my $string = string("foo\n");
  $string->chomp; # returns 1, $string == "foo"

Version

version 0.002011

Overview

This class provides a wrapper and methods for interacting with scalar strings.

Provided methods

•

new($value)

Constructs a new Data::Perl::String object, optionally initialized to $value if passed in, and returns it.

•

inc

Increments the value stored in this slot using the magical string autoincrement operator. Note that Perl doesn't provide analogous behavior in "--", so "dec" is not available. This method returns the new value.

This method does not accept any arguments.

•

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 ("s" in perlop). There is no way to provide the "g" flag, but code references will be accepted for the replacement, causing the regex to be modified with a single "e". "/smxi" can be applied using the "qr" operator. This method returns the new value.

This method requires two arguments.

•

match($pattern)

Runs the regex against the string and returns the matching value(s).

This method requires a single argument.

•

chop

Just like "chop" in perlfunc. This method returns the chopped character.

This method does not accept any arguments.

•

chomp

Just like "chomp" in perlfunc. This method returns the number of characters removed.

This method does not accept any arguments.

•

clear

Sets the string to the empty string (not the value passed to "default").

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.

•

substr

This acts just like "substr" in perlfunc. When called as a writer, it returns the substring that was replaced, just like the Perl builtin.

This method requires at least one argument, and accepts no more than three.

Releases

7 releases since Debian 8 (Jessie); the text changed 4 times.

  1. 8–9
  2. 10
  3. 11
  4. 12–13
  5. Arch

Author

Matthew Phillips <[email protected]>

From perl-data-perl 0.002011-8 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.