SPVM::StringBuffer - String buffer
use SPVM::StringBuffer; # new my $buffer = SPVM::StringBuffer->new; # push string $buffer->push("abc"); $buffer->push("def"); # Convert to string - abcdef my $str = $buffer->to_string; # Cat sub string - bcd my $offset = 1; my $length = 3; my $substr = $buffer->substr($offset, $length); # Search string my $search = "cd"; my $start_pos = 1; my $found_pos = $buffer->index($search, $start_pos); # new with option my $buffer = SPVM::StringBuffer->new_opt([(object)capacity => 256]);
String buffer. Performance is better than concat operator when many strings is joined.
sub new : SPVM::StringBuffer ()
Create new SPVM::StringBuffer object which capacity is 16 bytes without string
sub new_opt : SPVM::StringBuffer ($options : object[])
Create new SPVM::StringBuffer object with options.
capacity : SPVM::Int
Capacity of string buffer. Capacity must be more than 0.
sub length : int ($self : self)
Get string length.
sub capacity : int ($self : self)
Get capacity of string buffer.
sub push : void ($self : self, $string : string)
Push string to string buffer.
sub to_string : string ($self : self)
Convert string buffer to string.
sub substr : string ($self : self, $offset : int, $length : int)
Get sub string.
sub index : int ($self : self, $search : string, $offset : int)
Search string. Return value is position of found string.
If string is not found, Return value is -1.
sub clear : void ($self : self)
Clear string.
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.