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

Dear Monks, I am trying to implement a basic perl script, but I can't find a 'path to perl' and I don't really know where to look. Where is the directory normally found, and is there a chance I wouldn't have one? Sorry for being so incredibly stupid! Tom Hiskey.

Replies are listed 'Best First'.
Re: Very basic question!
by davorg (Chancellor) on Jul 10, 2000 at 22:40 UTC

    'Path to perl' is the directory where your Perl interpreter is installed. If you're on a Unix system you can often get a clue by typing

    which perl

    at your command line. The default installation directories under Unix are /usr/bin/perl or /usr/local/bin/perl. Sorry, but I don't know where Perl installs itself under Windows or on a Mac.

    --
    <http://www.dave.org.uk>

    European Perl Conference - Sept 22/24 2000, ICA, London
    <http://www.yapc.org/Europe/>
RE: Very basic question!
by jjhorner (Hermit) on Jul 10, 2000 at 22:43 UTC

    It depends on your system. If it is a Unix-based system, 'which perl' will give you an answer, and so will 'whereis perl'.

    If you are on an NT system, look in C:\Perl\bin for your perl.exe.

    You probably don't need this as often in NT as you may in Unix because of the ability to associate extensions with helpers.

    J. J. Horner
    Linux, Perl, Apache, Stronghold, Unix
    jhorner@knoxlug.org http://www.knoxlug.org/
    

      under activestate's distrobution of perl,
      the path to perl on the first line of a script
      as long as the perl is in your PATH statement
      all you've got to do is type 'perl srciptname.pl'
      from the command prompt OR double click on the
      icon, if you've associated the filetype w/ PERL

      personally, i assosciated my .pl files with a
      text editor

      Tangent Warning

      but that gives me a thought, does anyone know how to
      add multiple associations? ... something that will
      allow you to pull-up a little menu with right-click
      and have the choice to run, edit, copy, paste, blah...
      i wouldn't mind knowing how to do that if anyone
      knows off the top of their head

      i could even include 'open in excel' for text files and
      all sorts of neat stuff

      i'm sorry for the tangent :( i can't help it sometimes

        but that gives me a thought, does anyone know how to add multiple associations? ... something that will allow you to pull-up a little menu with right-click and have the choice to run, edit, copy, paste, blah... i wouldn't mind knowing how to do that if anyone knows off the top of their head

        Yes, you open an explorer window and go to the view menu, then options. There should be a tab that says file types. If you select this and then highlight the file type you want to alter, it will give you a list of options. One of these will be highlighted - this is the default, it will be invoked with a double click. The other options are available though a right click on the file in explorer or it's icon.

        You can edit actions that are already there, or add new ones. If you examine some of the actions on the filetypes that are already there, it will give you examples of the kind of things that you can do.

        Have Fun!

        P.S. Please don't tell anybody that I answered a windows question ;-)

        Nuance

        From explorer click view options or view Folder Options, and then click the File Types Tab

        Then, locate the file type you are interested in in the "Registerd file types" list box. Unfortunately, they are listed alphabetically by description rather than extension, so this may take a bit of seaching. Clicking on a description will show the extension(s) associated with it in the "File type details" box at the bottom of the dialog.

        Once you have found the type you are interested in, click the edit button. In the "Actions:" list box, you will see the currently associated actions for that file type. The one labeled "Open" and in bold is the default for double-clicking. Click the new button.

        In the "Action:" text-box, type the name that you want to see in the context(right-click) menu. E.g. "Edit with Textpad", or "Open in excell"

        In the "Application used to perform this action:" textbox, type the full path and filename of the application. E.g. c:\winnt\notepad.exe or "c:\Program Files\Microsoft Office\Office\excel.exe". NOTE: the "" around paths with spaces are required.

        If the program requires special command line parameters, you must use the % variable batch file standards to encode the command, with %1% being automatically set to the filename you are trying to open.
        E.g. "c:\Program Files\Microsoft Office\Office\excel.exe" /e "%1%"
        to start up excel suppressing the welcome screen and default blank workbook from displaying.

        Click the Ok button, and that dialog will close, and your action will be added to the "Actions" listbox. If you are working with a source code file, I would reccomend clicking the always show extension checkbox as well. Click Ok again, and you are back to the Options dialog. One final click of OK, and you are done.

        Now go to a file of the correct type, and right click. Your new action will be in the context menu, and clicking that menu option should bring the file up in the specified program if you did everything correctly.

        TO ALL:::: Sorry for the non-perl discussion here, but I figured it might help others as well.

Re: Very basic question!
by c-era (Curate) on Jul 10, 2000 at 22:40 UTC
    If you can type in perl from the command line, then type in "which perl" to get the path. Otherwise perl is usually in "/usr/local/bin", "/usr/bin", "/opt/bin", or "/bin".
Re: Very basic question!
by Anonymous Monk on Jul 10, 2000 at 23:53 UTC
    Yes, it is possible that you do not have a "path to perl" if perl is not installed on your system.

    You might wish to search for files or directories which have the word 'perl' in it. On a UNIX system which has the Korn shell installed, type 'cd /' followed by a return, 'ksh' followed by a return and then type 'find . -name *perl*' followed by a return.

    The directory which has the perl interpreter called 'perl' is probably your path. Add it to your existing path and also, in the Korn shell, type 'export PERL5LIB = "mypath";' where mypath is the directory you found.
RE: Very basic question!
by t0mas (Priest) on Jul 11, 2000 at 12:56 UTC
    On Unix, as root, you type:
    find / -name perl -print
    If nothing shows up, you're perless, and need to download perl and install it.

    /brother t0mas