Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Directory Structure Recommendations

by Ossie (Novice)
on Mar 20, 2017 at 12:14 UTC ( #1185251=perlquestion: print w/replies, xml ) Need Help??
Ossie has asked for the wisdom of the Perl Monks concerning the following question:

Hi Folks

As a newbie to Perl I'm seeking guidance about directory structure that is good practice, as I've not yet found it in the various documents I've looked at.

My primary objective is to run a program (Mapivi) under Perl on a Windows PC (I'll write my own additional code at later stage).

I've successfully installed Strawberry Perl and downloaded Mapivi together with other necessary files such as Perl/Tk and Image-MetaData-JPEG.

So what (if any) additional directories should I create to hold the various files when I unpack them, prior to running the usual sequence of Makefile & Test & Install, and should the resulting files be put into specific directories?

If there are existing publications covering this then I'd be grateful if you point me in their direction, as well as giving the benfit of your experience.

Related follow-on questions may then be about what has to be manually added to PATH and @INC

Thanks

Replies are listed 'Best First'.
Re: Directory Structure Recommendations
by marto (Bishop) on Mar 20, 2017 at 12:27 UTC

    "So what (if any) additional directories should I create to hold the various files when I unpack them, prior to running the usual sequence of Makefile & Test & Install, and should the resulting files be put into specific directories?"

    Welcome, are you aware that you can simply use cpanm to install modules and their dependencies? This method unpacks everything into a temporary area which is cleared up periodically. For example:

    cpanm Tk
Re: Directory Structure Recommendations
by thanos1983 (Priest) on Mar 20, 2017 at 15:18 UTC

    Hello Ossie,

    I agree 100% with marto, you should use CPAN to install the Perl modules. Take a look here: How to install CPAN modules.

    As a next step regarding Mapivi I found this really nice article (Mapivi 1.0 Preview).

    When you enter the article read also the Install Section where it contains all relevant information such as:

    ###################################################################### +#### # # Requirements # ###################################################################### +#### You need: o a computer running UNIX (Linux, Solaris, Mac OS X) and X11 or Window +s (mapivi also works at least with Windows 2000 and WinXP, but maybe a +lso with Windows 98) ###################################################################### +#### # # Installation of Perl modules # ###################################################################### +#### To install a Perl module you may either try cpan (a) or for Windows pp +m (b) or do a manual (c) install. (a) Cpan will download a module (and all modules it depends on), build and install it. All you have to do is open a shell and type: cpan module_name Example to install the Perl module Image::Info: cpan Image::Info

    This is just a sample just read through the document it contains useful information on how to install all necessary packages under WindowsOS/UnixOS and MacOS.

    Hope this helps.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
Re: Directory Structure Recommendations
by VinsWorldcom (Parson) on Mar 20, 2017 at 18:34 UTC

    Note you may have trouble getting Tk to install on Windows. I couldn't get it to build with the 'cpan' automated install. I needed to download the package, 'gunzip' and 'tar xf' into my ~/Downloads directory and then follow the advice here:

    Re: Problem installing TK module

      Thank you for the replies, especially the warning about potential problem with Perl/Tk under Windows

      Based on the reading I did prior to posting my question leads me to believe that know (falsely ??) HOW to install modules, but my question is WHERE guided by best practice & experience.

      My installation of Perl created the directory C:\Strawberry on my PC together with sub-directories such as \c and \cpan and \perl and \win32 and within those further sub-directories such as c:\Strawberry\cpan\sources\modules

      My instinct is to regard the installation of Mapivi as a separate “project” perhaps creating another directory such as c:\perl_project_mapivi

      I knew from the installation notes that Mapivi requires Perl/Tk plus other Perl modules (in CPAN) however I am seeking recommendations regarding the Directory Structure to adopt because I realise that I'll have to subsequently handle (at minimum) revision of Strawberry Perl, new version of Mapivi, updates to required modules, and the inclusion of self-written code.

      Experience says that adopting an appropriate directory structure at the outset of using a new language can ease subsequent changes and the evolution to further projects, hence my request for recommendations from wise monks or pointers to documentation that I've not yet been able to find.

      Many thanks in advance

        I see. When you install Perl modules (e.g., Tk) through automated 'cpan' or "manually" by downloading, gunzip, tar xf, and then the magical incantation (perl Makefile.PL, dmake, dmake test, dmake install) they will automatically be put in the appropriate directories for your installation - with Strawberry, most likely C:\Strawberry\perl\site\lib. This way, any Perl programs you write will be able to find them.

        For a separate "program" which will "use" Perl and the installed modules, you can put it anywhere you'd like. Some considerations, if it's command line, you may want the directory to be in your %PATH% environment variable. For example, I have a C:\usr\bin directory and added it to my path and it contains all the GnuWin32 tools as well as some Perl scripts I've written so when I open a cmd.exe Command Prompt, I can just type the Perl script name and it will run (you'll also need %PATHEXT% to include '.pl', but Strawberry installation generally takes care of this for you).

        I also have a Perl "project" - a script with many of it's own supporting modules not on CPAN, but available at GitHub, that I put into a sub-folder of C:\usr\bin (C:\usr\bin\ppc) and then created a batch file (ppc.bat) in C:\usr\bin that points to the Perl script (C:\usr\bin\ppc\bin\ppc.pl). This to limit the amount of folders in my %PATH% variable (as I have other projects setup this way).

        All of this way too much information? Maybe, but hopefully it shows you have some options and nothing says you can't change it later. So long as Perl and its CPAN modules are installed to their "default" location, things should for the most part run pretty smoothly.

        Hope that helps a little more.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1185251]
Front-paged by Corion
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2017-09-21 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (242 votes). Check out past polls.

    Notices?