Reputation: 57
I need help resolving the following variable ${$mapusers[$index]->[1]}
See below... It prints find. But when I do a system($query_user) the variable is empty.
my $query_user = 'adquery user -w ${$mapusers[$index]->[1]}';
Upvotes: 1
Views: 101
Reputation: 118166
If you want to run the adquery
command and store its output in $query_user
, use backticks or qx
:
my $query_user = `adquery user -w ${$mapusers[$index]->[1]}`;
Upvotes: 0
Reputation: 87401
Use "
instead of '
:
my $query_user = "adquery user -w ${$mapusers[$index]->[1]}";
system($query_user);
Or, if that one doesn't work, try this:
my $query_user = "adquery user -w " . $mapusers[$index]->[1];
system($query_user);
The first one should be used if $mapusers[$index]->[1]
is a scalar reference, and the second one should be used if $mapusers[$index]->[1]
isn't a reference.
If you want to capture the stdout of the command, use readpipe
instead of system
, or use the backtick operator.
Upvotes: 3