Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Problems with Data::Printer and prototypes

by mje (Curate)
on Mar 10, 2016 at 16:44 UTC ( [id://1157321]=perlquestion: print w/replies, xml ) Need Help??

mje has asked for the wisdom of the Perl Monks concerning the following question:

Hi fellow Monks

I have 2 machines both running perlbrew Perl 5.16.0 and both using the same version of Data::Printer. The small script below produces contradictory results on the 2 machines:

machine 1: $ perl --version This is perl 5, version 16, subversion 0 (v5.16.0) built for x86_64-li +nux $ perl -MData::Printer -le 'print $Data::Printer::VERSION' 0.36 $ cat /tmp/x.pl use 5.016; use strict; use warnings; use Data::Printer {alias => "pp", return_value => 'dump'}; my @x = (1,2,3); say pp(\@x); $ perl /tmp/x.pl Type of arg 1 to Data::Printer::p must be one of [@$%&] (not reference + constructor) at /tmp/x.pl line 8, near "@x)" Execution of /tmp/x.pl aborted due to compilation errors. Now edit script to take '\' out from the pp call and rerun: $ perl /tmp/x.pl [ [0] 1, [1] 2, [2] 3 ]
machine 1: $ perl --version This is perl 5, version 16, subversion 0 (v5.16.0) built for i686-linu +x $ perl -MData::Printer -le 'print $Data::Printer::VERSION' 0.36 $ cat /tmp/x.pl use 5.016; use strict; use warnings; use Data::Printer {alias => "pp", return_value => 'dump'}; my @x = (1,2,3); say pp(\@x); $ perl /tmp/x.pl [ 1, 2, 3 ] Now edit script to take '\' out from the pp call and rerun: $ perl /tmp/x.pl When calling p() without prototypes, please pass arguments as referenc +es at /tmp/x.pl line 8.

So on one one machine I'm told to pass a reference and on the other machine I'm told to not pass a reference. Any idea what is causing this? I'd like to run the same code on both machines but I cannot see why they differ.

Replies are listed 'Best First'.
Re: Problems with Data::Printer and prototypes
by graff (Chancellor) on Mar 10, 2016 at 17:10 UTC
    I've never used this module, but looking at the man page (Data::Printer), I see something in the "Extra Tips" section that might help. Maybe if you put the following in both copies of your script, you might get consistent behavior:
    use Data::Printer use_prototypes => 0;

      Thanks. That provided the hint. One machine has a .dataprinter file (with use_prototypes = 0) and the other does not.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1157321]
Approved by graff
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-23 06:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found