The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojo::Buffer - Buffer

SYNOPSIS

    use Mojo::Buffer;

    my $buffer = Mojo::Buffer->new('foo');
    $buffer->add_chunk('bar');
    my $foo = $buffer->remove(3);
    my $bar = $buffer->empty;

DESCRIPTION

Mojo::Buffer is a simple in-memory buffer.

ATTRIBUTES

length

    my $length = $buffer->length;

raw_length

    my $raw_length = $buffer->raw_length;

METHODS

Mojo::Buffer inherits all methods from Mojo::Base and implements the following new ones.

new

    my $buffer = Mojo::Buffer->new;
    my $buffer = Mojo::Buffer->new('foobarbaz');

add_chunk

    $buffer = $buffer->add_chunk('foo');

empty

    my $string = $buffer->empty;

get_line

   my $line = $buffer->get_line;

remove

    my $string = $buffer->remove(4);

replace

    $buffer = $buffer->replace('foobarbaz');

to_string

    my $string = $buffer->to_string;