NAME

    Syntax::Keyword::Inplace - syntax for making inplace changes to
    variables

SYNOPSIS

       use Syntax::Keyword::Inplace;
    
       my $var = "some value here";
       inplace uc $var;        # equivalent to  $var = uc $var;
    
       print $var;             # prints "SOME VALUE HERE"

DESCRIPTION

    This module provides a syntax plugin that implements a single keyword,
    inplace, which acts on function calls (or function-like perl operators)
    to make them modify the target expression.

    Perl has a large number of function-like operators that look at a
    single expression argument and return some new value based on it.
    Sometimes the result of calling one of these is immediately assigned
    back into the same variable again, in code that looks like $var =
    func($var). It is for these situations where this module is intended to
    apply.

KEYWORDS

 inplace

       inplace FUNC( EXPR )

    The inplace keyword modifies the behaviour of the following expression,
    which must be a function call or function-like core perl operator,
    which takes exactly one argument. That single argument must be valid as
    an lvalue (i.e. the target of an assignment). At runtime the function
    is called on that argument expression and the result of the function
    call is stored back into that expression.

       my $var = ...;
       inplace foo( $var );    # equivalent to  $var = foo( $var )

    If the expression is more complex than a single variable directly, then
    any side-effects involved in generating it only happen once.

       inplace foo( $hash{some_function_call()} );
    
       # equivalent to
       #   my $tmp_key = some_function_call();
       #   $hash{$tmp_key} = foo( $hash{$tmp_key} );

AUTHOR

    Paul Evans <leonerd@leonerd.org.uk>