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

hello fellow monks problem : I use storable library to store data , Using the stored data to create files . While i am using Retireve function of Storable Not able call other Functions of other library

code:

my $temp = retrieve 'test1';
$temp = $$temp;
my $spec = ClusterConfigSpecEx->new();

o/p : Can't load class 'ClusterConfigSpecEx' at /usr/share/perl/5.14/VMware/VIMRuntime.pm line 52.

if i remove the Storable library from the script i am able to create the Spec object Can you Help me Thank you

  • Comment on Storable library is masking the other libraries of perl

Replies are listed 'Best First'.
Re: Storable library is masking the other libraries of perl
by kcott (Archbishop) on Jan 12, 2014 at 14:16 UTC

    G'day santoshsas02,

    Welcome to the monastery.

    From your problem description, it sounds like you may have a typo somewhere near code that looks like:

    use Storable; use ClusterConfigSpecEx;

    It could be something as simple as a missing semicolon; however, without seeing that part of your code, I can only guess. If that doesn't help, you'll need to post more code for us to help you further.

    The strict and warnings pragmata will often identify typos such as this. If you're not already using these, I strongly recommend you do.

    Probably unrelated to your reported issue, but the code

    my $temp = retrieve 'test1'; $temp = $$temp;

    is potentially confusing and may prove to be error-prone (particularly if changes are made to this part of your script at some later date).

    If you did store a scalar value, e.g.

    store \$scalar_to_store, 'test1';

    then retrieval as

    my $retrieved_scalar = ${retrieve 'test1'};

    would reduce confusion over the intent and you wouldn't be using the same variable as both reference and dereference values.

    -- Ken

Re: Storable library is masking the other libraries of perl
by Preceptor (Deacon) on Jan 12, 2014 at 13:59 UTC

    Insufficient detail in your code sample. In normal situations, if you have a namespace clash on imported modules, the way to handle it is turn off the automatic importing, by specifying:

    use Storable ();

    This will then not import any of 'Storables' namespace, and you can call subroutines via full name. e.g.:

    Storable::store \%table, 'file';
Re: Storable library is masking the other libraries of perl
by Anonymous Monk on Jan 12, 2014 at 11:56 UTC
    That isn't a feature of Storable library :) which version do you have?