diff --git a/lib/PPI/Node.pm b/lib/PPI/Node.pm index ac7d4b99..a7f56e9a 100644 --- a/lib/PPI/Node.pm +++ b/lib/PPI/Node.pm @@ -714,40 +714,40 @@ sub __position { # Insert one or more elements before a child sub __insert_before_child { - my $self = shift; - my $key = refaddr shift; + my ( $self, $child, @insertions ) = @_; + my $key = refaddr $child; my $p = List::Util::first { refaddr $self->{children}[$_] == $key } 0..$#{$self->{children}}; - foreach ( @_ ) { + foreach ( @insertions ) { Scalar::Util::weaken( $_PARENT{refaddr $_} = $self ); } - splice( @{$self->{children}}, $p, 0, @_ ); + splice( @{$self->{children}}, $p, 0, @insertions ); 1; } # Insert one or more elements after a child sub __insert_after_child { - my $self = shift; - my $key = refaddr shift; + my ( $self, $child, @insertions ) = @_; + my $key = refaddr $child; my $p = List::Util::first { refaddr $self->{children}[$_] == $key } 0..$#{$self->{children}}; - foreach ( @_ ) { + foreach ( @insertions ) { Scalar::Util::weaken( $_PARENT{refaddr $_} = $self ); } - splice( @{$self->{children}}, $p + 1, 0, @_ ); + splice( @{$self->{children}}, $p + 1, 0, @insertions ); 1; } # Replace a child sub __replace_child { - my $self = shift; - my $old_child_addr = refaddr shift; + my ( $self, $old_child, @replacements ) = @_; + my $old_child_addr = refaddr $old_child; # Cache parent of new children my $old_child_index = List::Util::first { @@ -756,14 +756,14 @@ sub __replace_child { return undef if !defined $old_child_index; - foreach ( @_ ) { + foreach ( @replacements ) { Scalar::Util::weaken( $_PARENT{refaddr $_} = $self ); } # Replace old child with new children - splice( @{$self->{children}}, $old_child_index, 1, @_ ); + splice( @{$self->{children}}, $old_child_index, 1, @replacements ); # Uncache parent of old child delete $_PARENT{$old_child_addr};