Module::Generic::Scalar - String Manipulation Object Class
my $s = Module::Generic::Scalar->new( "John Doe" ); print( $s->substr( 0, 4 ), "\n" ); # prints: John
The purpos of this calss/package is to provide an object-oriented approach to string manipulation.
The object is overloaded, so it returns the embedded string when used as a string.
print( "I met with $s\n" );
Would produce: I met with John Doe
Provided with scalar reference, an array or just a regular string and this returns a new object.
If an array reference or an array-based object is provided like Module::Generic::Array, this will concatenate all the array elements
Returns the object string as a string.
my $s = Module::Generic::Scalar->new( "Mary Jane" ); print( "Hello $s\n" ); # Hello Mary Jane
Just like "chomp" in perlfunc, this remove the trailing new lines in the string, if any.
Just like "chop" in perlfunc, this remove the trailing character in the string, no matter what it is.
Just like "fc" in perlfunc, provided with a string, this enables comparison with casefolding.
To quote from the manual: "Casefolding is the process of mapping strings to a form where case differences are erased".
lc($this) eq lc($that) # Wrong! # or uc($this) eq uc($that) # Also wrong! # or $this =~ /^\Q$that\E\z/i # Right! # And now my $s = Module::Generic::Scalar( $this ); $s->fc( $that );
Returns the hex value of the string.
Given a sub string and an optional position, and this returns the position at which the sub string was found.
See "index" in oerlfunc
Given a string, this return a new Module::Generic::Scalar object with the string all in lower case.
Given a string, this return a new Module::Generic::Scalar object with the first character of the string in lower case.
This returns the length of the string, as a Module::Generic::Number object.
This returns the value of "ord" in perlfunc on the string, as a Module::Generic::Number object.
Given a string, this return a new Module::Generic::Scalar object with the given string characters escapeed with "quotemeta" in perlfunc.
This empty the string inside the object.
Given a string, this return a new Module::Generic::Scalar object with the given string cin reverse order.
Given a sub string and an optional position, and this returns the position at which the sub string was found, starting from the end.
See "rindex" in oerlfunc
Provided with a scalar reference or scalar-based object like Module::Generic::Scalar or an array reference and this sets the current string/.
This acts the exact same way as for "new", except it acts on the current object string.
Provided with a string or an expression and this returns the list in list context or, in scalar context, an array reference as an Module::Generic::Array object.
Provided with a list of arguments, and this replace the placeholders just like "sprintf" in perlfunc does.
Provided with an offset, an optional length and an optional replacement string, and this return a new Module::Generic::Scalar object.
See "substr" in perlfunc for more information.
Given a string, this return a new Module::Generic::Scalar object with the string all in upper case.
Given a string, this return a new Module::Generic::Scalar object with the first character of the string in upper case.
Module::Generic::Number, Module::Generic::Array, Module::Generic::Boolean, Module::Generic::Hash, Module::Generic::Dynamic
Jacques Deguest <jack@deguest.jp>
Copyright (c) 2000-2020 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
To install Module::Generic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Module::Generic
CPAN shell
perl -MCPAN -e shell install Module::Generic
For more information on module installation, please visit the detailed CPAN module installation guide.