Mojo::Parameters(3p)

NAME
Mojo::Parameters - Parameter container

SYNOPSIS
  use Mojo::Parameters;

  my $p = Mojo::Parameters->new(foo => 'bar', baz => 23);

DESCRIPTION
Mojo::Parameters is a container for form parameters.

ATTRIBUTES
Mojo::Parameters implements the following attributes.

  "charset"
  my $charset = $p->charset;
  $p          = $p->charset('UTF-8');

Charset used for decoding parameters, defaults to "UTF-8".

  "pair_separator"
  my $separator = $p->pair_separator;
  $p            = $p->pair_separator(';');

Separator for parameter pairs, defaults to "&".

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

  "new"
  my $p = Mojo::Parameters->new;
  my $p = Mojo::Parameters->new('foo=b%3Bar&baz=23');
  my $p = Mojo::Parameters->new(foo => 'b;ar', baz => 23);

Construct a new Mojo::Parameters object.

  "append"
  $p = $p->append(foo => 'ba;r');

Append parameters.

  # "foo=bar&foo=baz"
  Mojo::Parameters->new('foo=bar')->append(foo => 'baz');

  "clone"
  my $p2 = $p->clone;

Clone parameters.

  "merge"
  $p = $p->merge($p2, $p3);

Merge parameters.

  "param"
  my @names = $p->param;
  my $foo   = $p->param('foo');
  my @foo   = $p->param('foo');
  my $foo   = $p->param(foo => 'ba;r');
  my @foo   = $p->param(foo => qw/ba;r ba;z/);

Check and replace parameter values.

  "params"
  my $params = $p->params;
  $p         = $p->params([foo => 'b;ar', baz => 23]);

Parsed parameters.

  "parse"
  $p = $p->parse('foo=b%3Bar&baz=23');

Parse parameters.

  "remove"
  $p = $p->remove('foo');

Remove parameters.

  # "bar=yada"
  Mojo::Parameters->new('foo=bar&foo=baz&bar=yada')->remove('foo');

  "to_hash"
  my $hash = $p->to_hash;

Turn parameters into a hash reference.

  # "baz"
  Mojo::Parameters->new('foo=bar&foo=baz')->to_hash->{foo}->[1];

  "to_string"
  my $string = $p->to_string;

Turn parameters into a string.

SEE ALSO
Mojolicious, Mojolicious::Guides, <http://mojolicio.us>.