Reputation: 40778
I was experimenting with the Data::Printer
module, and it worked fine until
I tried to print the return value of a system call using qx operator:
use strict;
use warnings;
use Data::Printer;
p qx/echo -n Hello/;
This gives me the following error:
Type of arg 1 to Data::Printer::p must be one of [@$%&] (not scalar)
I assume this error occurs because qx
is not recognized as a scalar, hash, array, or function. So I tried:
p my $temp = qx/echo -n Hello/;
and it worked fine. The question is, if it is possible to avoid the use of the $temp
variable? (I think this syntax would become annoying to use and remember in the long run)
Upvotes: 0
Views: 51
Reputation: 126742
Unlike Data::Dumper
and Data::Dump
, the default mode of Data::Printer
allows you to display only the contents of variables, not arbitrary expressions
This behaviour can be circumvented by disabling the use_prototypes
option in the use
statement, when arrays and hashes must be passed explicitly by reference
use Data::Printer use_prototypes => 0, output => 'stdout';
p qx/echo -n Hello/;
"Hello"
Upvotes: 1