Re: path to perl on umbuntu
by marto (Cardinal) on Oct 27, 2010 at 13:33 UTC
|
Welcome to the Monastery
Typing which perl at the command line will tell you where perl lives. Clearly there is a top level usr directory (/usr) otherwise /usr/bin wouldn't exist. Perhaps you should spend some time learning about the linux file system. Searching google is sure to result in some decent tutorials on the subject.
Regarding perl on Ubuntu I'd suggest installing your own version else where. Perl which ships with Ubuntu is used by the OS, I'd strongly advise against messing around with it. It's much safer (and a good learning experience) to install your own version.
See (Help Needed) Uninstall Perl 5.10 and Install 5.8 on Ubuntu 10.04 for reasons not to mess with the system perl and how to install your own version elsewhere on the system.
Update: fixed a couple of typos.
| [reply] [d/l] [select] |
|
|
Thanks for your reply. I will look at downloading and installing another version of Perl. Is there somewhere specific where I should install it? Presumbly I then have to change the line at the top of my perl scripts from #!/usr/bin/perl to this new path?
Also if I then need to use CPAN to download new perl modules etc, how will CPAN know to put these in my new perl installation path and not the system perl?
| [reply] |
|
|
When configuring perl you could tell it to install in /opt/perl:
./Configure -des -Dprefix=/opt/perl
Be sure to read the Readme and INSTALL files prior to installation. Your newly built perl will have it's own version of cpan (in the example above under /opt/perl/bin/cpan), it knows where to put modules.
| [reply] |
|
|
|
|
|
|
|
| [reply] [d/l] [select] |
|
|
|
|
Hi again
I'd like to understand why I need to install a new version of Perl. I'm not arguing because I don't have any knowledge to argue. I am wondering how, if I install any modules I use in a specific local directory and add that to the Perl5Lib classpath (or whatever its called in Perl, sorry), I could do any damage to anything? thanks
| [reply] |
|
|
| [reply] |
|
|
|
|
Re: path to perl on umbuntu
by raybies (Chaplain) on Oct 27, 2010 at 13:35 UTC
|
Judging solely from your question, I would guess you'd best be served by learning a bit more about linux in general. Are you familiar with the concept of a file path?
You may also wish to learn a bit about the tools on your new linux install, like how to edit text, how to change file permissions, and how to manage a user account.
Once you learn a bit about your operating system, I suggest you get ahold of a basic tutorial for Perl. Most of them start with a discussion of what it takes to run a program. I suggest you go to Google and type "Perl Tutorials" and you'll see hundreds of links on how to get started.
Here's a simple HelloWorld program to get you started. Save this file in a text file and make it executeable. (Though if you're not familiar with that idea, you'll want to consult a book on Linux first).
#!/usr/bin/perl
print "Hello World";
Good luck... | [reply] [d/l] |
Re: path to perl on umbuntu
by locked_user sundialsvc4 (Abbot) on Oct 27, 2010 at 15:06 UTC
|
First of all: Do not feel alone in this! I am extremely sympathetic to your plight, and I can point to several damaged walls (and slightly-bent books and desktop objects that still won’t speak to me) to prove it.
Next: Be prepared for “a sip from the firehose.” These things, too, shall pass. It will all make sense. It will not do so right away. It will seem that it never could.
Next, a few random thoughts:
-
If Perl is installed on the computer now, you probably do not need to install another version. But in addition, you do not want to disturb the installation that is there, if (say...) any Umbuntu system management software might depend on it. If that Perl installation is being maintained using packages, vs. CPAN, you probably do not want to disturb it. This is possible.
-
You need to “Google” for more information about how CPAN works, and “how to set up Perl as a non-root user.”
-
Type perl -V ... note the capital “V” ... and ponder the results. Particularly the last bit ... a little variable called @INC. (Mind you, I am not being “coy.” As you read what I have asked you to read, it will all come clear.)
Perl refers to various environmental settings, such as the variable PERL5LIB. CPAN, likewise, uses settings which it stores in a hidden file. It is therefore possible to set up your own, local, “Perl library,” managing it by CPAN and doing so without disturbing what Umbuntu may be doing. The situation is exactly like the one faced by a person who is setting up Perl for use on a website in a shared-hosting ISP: this is a computer that the various website owners do not own, and each website (there might be hundreds on the same box) can have its own peculiar Perl configuration apart from all the others. And that is why I have pointed you specifically to such documents.
| |
|
|
Hi
I understand that I can use the Perl5LIB env variable to modify the @INC files. That was what I was going to do in the first place before this thread advised me to leave the sysytem perl alone :)
On that issue My problem is more with Linux and CPAN than Perl. I have looked into how CPAN works but I don't know how I configure CPAN to install modules to a specific location. Also when I get modules I want, they will have dependencies on other modules and CPAN might get new versions of these modules. I don't know if this will have bad affects on any system perl that depends on these 'updated' modules.
Many thanks for your help
| [reply] |
|
|
You might find some helpful guidance in Yes, even you can use CPAN Installing Modules Without Root.
If your personal library appears before the system libraries in the @INC variable (the list of directories perl searches for modules) then perl will find the modules you have installed and use them instead of whatever version is in the system libraries. You may have issues with dependencies but you can install as much as you want/need to in your personal library to satisfy those dependencies. This will work until you need perl itself to be different (e.g. different compile time options). But this isn't likely to be a problem in the short term.
| [reply] |
Re: path to perl on umbuntu
by Utilitarian (Vicar) on Oct 27, 2010 at 15:27 UTC
|
Hi,
One final word of warning/advice to go with the rest.
Ubuntu uses the Debian advanced package tools (apt) if you need to add a CPAN library and do not install your own perl you should use apt to manage your modules rather than the cpan shell, most modules will be of the form libcollection-module-perl where the original module was Collection::Module. ~You can find them easily with the following ~/$ apt-cache search Collection::Module
and the install with the command~/$ sudo apt-get install libcollection-module-perl
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
| [reply] [d/l] [select] |
|
|
This is a total pain!! :)
I've looked at CPAN and read how to install modules if you are not a root user. However I still can't find anything to tell me how I can specify where CPAN installs the module to so that I could, if i wanted, install a module to my own code library.
If i am missing something obvious, please feel free to spell it out to me like I am a 4 year old child who's not very good with computers
| [reply] |
|
|
apt-get update
apt-get install \
lynx unzip zip ncftp gcc libc6-dev make mysql-server apache2 \
perl libgd-gd2-perl libcgi-session-perl libclass-base-perl
apt-get clean
Are any of the things in this list specific to a version of perl because they are installed using apt-get so they will be available to the system perl and not my local perl if that is the case?
With my limited knowledge I think these files
libgd-gd2-perl libcgi-session-perl libclass-base-perl are perl modules in apt-get format and so will be installed for the system perl. But i should be able to use CPAN for my new local perl and install the CPAN version of them? | [reply] [d/l] [select] |
|
|
Re: path to perl on umbuntu
by fisher (Priest) on Oct 28, 2010 at 06:20 UTC
|
I think the general convention is to store your code somewhere in your $HOME and use
#!/usr/bin/env perl
as a very first line in your scripts. This will work on *BSD (/usr/local/bin/perl) and most Linux distributions (/usr/bin/perl), and I personally ran this on Solaris (/opt/cantremeber/perl).
| [reply] [d/l] |
|
|
Greetings all,
After reading this entire thread, I couldn't help but motice the _glaring_ omission of the most helpful tool for a *NIX newbie -- man,
man is your friend - not to be confused with "the" man, who is probably _not_ your friend. ;)
perldoc is also your friend -
~$ perldoc perl
Something else you will surely want to discover, is what
shell you are using.
Almost all Linux distros supply bash
as the default shell.
Personally, I find csh to be a real
good choice - the first thing I change when I install Linux
on any of my servers/workstations.
If memory serves, it's
found as tcsh on Linux.
The reason I bring up your shell, is that it holds/comprises
most of the ENVironment you work in.
This also affects your
perl installation(s). So the first thing I'd do _before_
messing around with your/a perl installation, would be to
discover what your default shell is.
Examine some of the
others available. Decide which one is for you. _Then_ start
on your perl project(s).
The shell ENVironment is _truly_
a pre-requisite to doing _anything_ on your fresh *NIX
install - really!
If you're more comfortable in a web browser, than at the
terminal (not a good sign if you're on a *NIX boxen), I've
cobbled up an online MANual interface in perl. It allows
anyone to lookup system man pages, as well as any perl man
(pod) pages, and modules. Try this one first:
http://www.perlwatch.net/man/?query=shell
After that, you can enter things like csh bash perl,
or even Pod::Parser - _yes_ with the colons. :)
Then you can try the same at your terminal. :)
Personally, I _would_ choose to install a copy of perl somewhere
within your $HOME directory. But _do_ read up on your shell
environment beforehand. It will ultimately make your final
decision, and final experience _much_ smoother/happier.
HTH, and best wishes.
--Chris
| [reply] [d/l] |