The value of can be expressed in the format & lt; value & gt; . You can also use it to create new values such as %Perl .
It maps to the following parameters:
{ title =>'%Perl', price => 1000, a =>'%Ken%' }
Keys not specified in the map method will not be mapped. The key b is not mapped in this example.
If you want to change the value a little more flexibly, you can use the subroutine reference. Since the original value can be obtained with the first argument, the new value is returned.
Original key name => [new key name => sub {return'%'. $_[0].'%'}]
Parameter mapping conditions
The default mapping conditions are as follows:
The value is defined and has a length
So the following parameters are mapped.
title =>'Perl',
However, anything that does not have an empty string, undefined value, or the key itself is not mapped. This is because the mapping is intended for web applications.
title =>'', title => undef
Use the condition attribute to change this condition. You can set the reference of any subroutine or the strings "length", "defined", and "exists" as special values.
$mapper->condition('length'); # Same as default $mapper->condition('defined'); # value is defined $mapper->condition('exists'); # key exists $mapper->condition(sub {defined $_[0]}); # Reference to any subroutine
It is also possible to set each key individually as follows with the map method.
$mapper->map( Old key => [new key => new value, {condtion =>'defined'}], );