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

I just downloaded my first module that wasn't part of the original build. It's called Win32::Clipboard.

I saved the file, Clipboard.pm to C:\strawberry\perl\lib\Win32\Clipboard.pm

I had to create the win32 subdirectory to put it there. Then I put use Win32::Clipboard; in my code, on line 5.

When I run it, the error is as follows: Can't locate loadable object for module Win32::Clipboard in @INC (@INC contains: C:/strawberry/perl/site/lib C:/strawberry/perl/vendor/lib C:/strawberry/perl/lib .) at cp.plx line 5.

I tried several things; using Win32.pm, looking for other supplemental files associated with Clipboard, moving Clipboard around to other directories, running something called ppm to install win32-Clipboard, but it said "Error installing package 'win32-Clipboard': Could not locate a PPD file for package win32-Clipboard"

Any ideas?

Thanks,
Jonathan

Replies are listed 'Best First'.
Re: How do I use a module?
by bulk88 (Priest) on Mar 25, 2014 at 04:16 UTC
Re: How do I use a module?
by ww (Archbishop) on Mar 25, 2014 at 01:57 UTC

    The first move that you've given us enough info to work with is in the narrative note "...running something called ppm to install win32-clipboard."

    That should work; it does when searching or installing with Active State's ppm and correct syntax; in fact, it works there even with the caps borked (YMMV with whatever repos Strawberry uses). So please show us just how you invoked ppm... and maybe even tell us you read the documentation (help file).

    These nodes/threads may be useful:

    Also, please read about Markup in the Monastery. Your doubled (unmatched) para tags are incorrect... as was your attempt to use <pre> tags, rather than <c> (code) tags. Writeup Formatting Tips may also help.

    Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
    1. code
    2. verbatim error and/or warning messages
    3. a coherent explanation of what "doesn't work actually means.
Re: How do I use a module?
by davido (Cardinal) on Mar 25, 2014 at 22:20 UTC

    When did Strawberry Perl begin using ActiveState's ppm utility?

    Correctly installing modules isn't just a matter of copying files into some path. There's more to it than that. Fortunately, Strawberry Perl gives you most of what you should need. I've got a clean install of Strawberry Perl on a VM that I was able to test. All I had to do was type:

    cpan install Win32::Clipboard

    ...and presto. No messing around with copying things all over the place, and the XS component was compiled correctly for me.

    Update: I stand corrected on the ppm question. Nevertheless, the method for installing using cpan install Win32::Clipboard works, and is probably the preferred means.


    Dave

      When did Strawberry Perl begin using ActiveState's ppm utility?

      They have been using PPM since the very beginning, even before 2009

Re: How do I use a module?
by JDoolin (Novice) on Mar 26, 2014 at 12:29 UTC

    Thank you to everyone that replied.

    Looks like it is working, thanks to your help, and some guessing, and checking. I will include the unsuccessful steps I took, in case they may have done something that was necessary.

    Unsuccessful steps.

    1. Ran cpan install Win32::Clipboard: The installation appeared to be successful, but the Error: Can't locate loadable object for module Win32::Clipboard remained.
    2. I removed Clipboard.pm from the \perl\lib folder, then tried cpan install Win32::Clipboard again. This time, it failed to install, with error Failed 1/1 test programs. 1/9 subtests failed.

    Successful Steps.

    1. I placed Clipboard.xs in the \perl\lib folder
    2. I changed the extension on Clipboard.xs to Clipboard.pm.
    3. Ran cpan install Win32::Clipboard: This time the installation appeared to succeed, and the perl script appeared to access the clipboard.

    Follow-up Question

    Am I using the .xs file in the intended manner? My guess would be that the .xs file might be a version of the pm file, made for people that don't have C++ on their systems. Is it supposed to be renamed as a .pm file, or am I doing something weird?

      Unsuccessful steps.

      1. Ran cpan install Win32::Clipboard: The installation appeared to be successful, but the Error: Can't locate loadable object for module Win32::Clipboard remained.
      2. I removed Clipboard.pm from the \perl\lib folder, then tried cpan install Win32::Clipboard again. This time, it failed to install, with error Failed 1/1 test programs. 1/9 subtests failed.


      Why dont you post the full log? You obviously aren't compiling C code.

      Am I using the .xs file in the intended manner? My guess would be that the .xs file might be a version of the pm file, made for people that don't have C++ on their systems. Is it supposed to be renamed as a .pm file, or am I doing something weird?

      I suggest you read that .xs file and decide if it written in Perl language or not and report back with your answer ;)
      Well, I believe most of your problem stem from manual copying of files, all willy nilly :)
Re: How do I use a module?
by Anonymous Monk on Mar 25, 2014 at 15:42 UTC