in reply to Get outputs from 2 commands and add to var

The binary operator dot takes two arguments and concatenates the data from the right operand to the left operand. Combine with an equal sign to concatenate and assign with one operator.

my $data = $self->cmd('show run', undef, $output_ref, qr/^(?![:!])/); $data .= 'appended data'; # Equivalent to $data = $data . 'appended data';

Additive Operators

my $data = $self->cmd('show run', undef, $output_ref, qr/^(?![:!])/); $data .= $self->cmd('some other command', undef, $output_ref, qr/^(?![ +:!])/);

You also have to think about context. You probably don't want to append a list to a scalar. If $self->cmd returns a list, that's what you would be doing.

use strict; use warnings; sub something { return (3,4,5) }; my $x = 'some data'; #scalar $x .= something; #list print $x; # some data5 print "\n"; print something; # 345