Finally got it to work (with lots of warnings) by using plain old Safe. I couldn't get a proper run with Safe::World. I guess is not ready for stable use yet. It has a similar interface to Safe though so one can easilly port to it once it's a bit more stable. Keep up the good work gmpassos.

Thanks to all the monks that have helped me.

Update:

I might be doing it all wrong. I have replacated the failing part(s) here.

This should print 144.

#!/usr/bin/perl use strict; use warnings 'all'; use Safe::World; my ($stdout, $stderr); my $world = Safe::World->new( stdout => \$stdout, stderr => \$stderr, ); print "World created\n"; $world->eval('print 12 ** 2, "\n";'); die $@ if $@; print $stdout, "***End***\n"; # CLEANup should follow

The output produced is the followng (paths foobared):

Scalar value @_[0] better written as $_[0] at .../Safe/World/ScanPack. +pm line 88. Scalar value @_[0] better written as $_[0] at .../Safe/World.pm line 3 +45. Useless use of hash element in void context at .../Safe/World.pm line +1007. Use of uninitialized value in string eq at .../Safe/World.pm line 170. Use of uninitialized value in numeric ne (!=) at .../Safe/World.pm lin +e 344. World created Use of uninitialized value in numeric ne (!=) at .../Safe/World.pm lin +e 386. syntax error at (eval 18) line 1, near "=" Use of uninitialized value in numeric ne (!=) at .../Safe/World.pm lin +e 943. Use of uninitialized value in numeric ne (!=) at .../Safe/World.pm lin +e 956. Use of uninitialized value in numeric ne (!=) at .../Safe/World.pm lin +e 386. Use of uninitialized value in numeric ne (!=) at .../Safe/World.pm lin +e 386. Use of uninitialized value in string ne at .../Safe/World/stdout.pm li +ne 218. Use of uninitialized value in string ne at .../Safe/World/stdout.pm li +ne 218.

In reply to Re: Unloading a module completely by holo
in thread Unloading a module completely by holo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.