Skip to content

[doc] perlref postfix dereference can be used on LHS #22130

@epa

Description

@epa

Where
perlref section Postfix Dereference Syntax

Description
The documentation is accurate to say that postfix deref works in all cases where block deref does. But it doesn't specially mention that this includes on the LHS of an assignment. It could do with a mention of
$aref->@* = (1, 2, 3); # same as @{ $aref } = (1, 2, 3)
just to reassure the reader.

(what follows is more of an opinion and might or might not be suitable for incusion in perlref) Perhaps a common usage of postfix on the LHS would be for
$aref->@* = foo();
This is, of course, not equivalent to
$aref = [ foo() ];
but it can be a good enough replacement in many cases, when you know $aref was undefined before, and is visually easier to read.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions