How to include and use pm files in perl

include, package, perl, perl-module

Solution

Perl expects to find `Foo::Bar::Baz` in `$PERL5LIB/Foo/Bar/Baz.pm`

It also expects the modules to come with their dependencies. Don't just copy the specific `.pm` file. Install the module properly using `cpanm` (or `cpan` or another CPAN installer).

You seem to be using Windows…

If you are using ActiveState Perl, then you probably should look to its PPM installer.

If you are using Strawberry Perl, then it will have a cpan installer and you can just run:

cpan Net::OAuth2::Client

on the command line.

Problem

Ok this is how the main file uses those include pm files ``` use Dancer; use Net::OAuth2::Client; use HTTP::Request::Common; sub client { Net::OAuth2::Client->new( '0', # OAuth 2.0 client_id '1234567890abcdef', # OAuth 2.0 client_secret site => 'http://www.deviantart.com', authorize_path => 'https://www.deviantart.com/oauth2/draft15/authorize?response_type=code', access_token_path => 'https://www.deviantart.com/oauth2/draft15/token?grant_type=authorization_code', access_token_method => 'GET', )->web_server( redirect_uri => uri_for('/auth/deviantart/callback') ); } ``` I have put those PM files in same directory as this but it fails because can not locate Those files begins like this ``` package Net::OAuth2::Client; package HTTP::Request::Common; package Dancer; ```

Original source