in reply to Safe.pm, Barcode::DataMatrix, Can't locate object method "new" via package "Barcode::DataMatrix"

From looking at the docs for Safe I don't think you are passing the correct arguments:
$safefuncs->share( 'Barcode::DataMatrix' ); $safefuncs->share_from('main', [ 'DataMatrix2d' ]);
'Barcode::DataMatrix' is being treated as a function name. You could try:
$safefuncs->share_from( 'Barcode::DataMatrix', \@safeops ); $safefuncs->share_from( 'main', [ 'DataMatrix2d' ]);
From the docs:
share (NAME, ...)
This shares the variable(s) in the argument list with the compartment... Each NAME must be the name of a non-lexical variable, typically with the leading type identifier included. A bareword is treated as a function name.
share_from (PACKAGE, ARRAYREF)
This method is similar to share() but allows you to explicitly name the package that symbols should be shared from. The symbol names (including type characters) are supplied as an array reference.
  • Comment on Re: Safe.pm, Barcode::DataMatrix, Can't locate object method "new" via package "Barcode::DataMatrix"
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Safe.pm, Barcode::DataMatrix, Can't locate object method "new" via package "Barcode::DataMatrix"
by Tharg (Scribe) on Jul 19, 2015 at 16:29 UTC
    No luck, I'm pretty sure \@safeops doesn't belong there (they are opcodes). I'm also sure the wrong args there - I've tried all sorts of combinations and the ones pasted above are just what I had in at that time. Most things I've tried give exactly the same errors / warnings. However I tried this (which I do not claim to understand, I'm just bashing the keyboard) :
    $safefuncs->share_from('main', [ 'DataMatrix2d', 'Barcode::DataMatrix: +:new' ]);
    and got a new error / warning :
    C:\Users\XX\TestSafe>perl TestSafe.pl Can't locate package Moose::Object for @Barcode::DataMatrix::ISA at Te +stSafe.pl line 13. (in cleanup) Undefined subroutine &Barcode::DataMatrix::new ca +lled at TestSafe.pl line 13.
      What about:
      $safefuncs->share_from( 'Barcode::DataMatrix', ['new','barcode'] );
        Usual error :
        C:\Users\XX\TestSafe>perl TestSafe.pl (in cleanup) Can't locate object method "new" via package "Bar +code::DataMatrix" (perhaps you forgot to load "Barcode::DataMatrix"?) + at TestSafe.pl line 13.