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

I recently had to reinstall Mac OS X, and I didn't have the extra disk that gives you a full Perl install.

There I was, with Perl, but with almost no modules, and I had almost no idea what I could achieve with just the Perl application, no extras no modules no nothing.

Just about everything interesting I've ever done with Perl has used one module or other. Where does Perl end and the modules begin? Did I really have Perl if I didn't have the modules that come with it?



($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print

Replies are listed 'Best First'.
Re: What could I do with just Perl?
by Zaxo (Archbishop) on Nov 29, 2003 at 06:20 UTC

    Do you have make, yacc, and a C compiler? If so, reinstall from source (there may be other requirements). There's no sense putting up with a botched installation. Importants parts of perl live in the libraries.

    After Compline,
    Zaxo

Re: What could I do with just Perl?
by samtregar (Abbot) on Nov 29, 2003 at 07:21 UTC
    You could waste a lot of time, that I can promise you! I've known a number of Perl programmers that never use modules written by other people. Their reasoning is usually that they can't be sure the code is good enough or they can't be bothered. Instead, they end up reinventing wheel after wheel.

    Don't put up with a broken Perl install. Just download the source and compile your own. Then boot up CPAN.pm and figure out which pieces you really need to invent!

    -sam

      Their reasoning is usually that they can't be sure the code is good enough or they can't be bothered. Instead, they end up reinventing wheel after wheel.
      The vanity! Not only do they reinvent the wheel, but unless they spend a huge amount of time on their own code, what they end up with will most likely be of inferior quality to most of what you can find on CPAN.

      Shop around. You'll save huge amounts of time, and end up with fewer bugs.

Re: What could I do with just Perl?
by jweed (Chaplain) on Nov 29, 2003 at 06:20 UTC
    Well, technically, everything. Most modules are pure perl, and you could really copy and paste their code into your own. Perl is very powerful on its own, and I'd say that I spent a good time of my early perl experience playing around with the language sans module functionality.


    Who is Kayser Söze?
Re: What could I do with just Perl?
by davido (Cardinal) on Nov 29, 2003 at 08:54 UTC
    A lot more than you could do with "just C". Can you imagine C without any libraries and #include headers?

    I have a crippled Perl 5.6.1 on my Sharp Zaurus PDA. Some modules are there, others aren't. It's a big enough pain in the rear that I've mostly gotten away from using Perl on the Z, and instead, use the Z as a perldoc reader and Perl CD Bookshelf reader (I've got my CF card loaded up with those gems).


    Dave


    "If I had my life to live over again, I'd be a plumber." -- Albert Einstein
Re: What could I do with just Perl?
by xenchu (Friar) on Nov 29, 2003 at 14:05 UTC

    By all means reinstall Perl as Zaxo suggests. Then download yum from Duke University and ask it what modules you need. I am the most ignorant Perl programmer in the world and I can get it to work. If you are not familiar with it yum = Yellowdog Updating Module. I think it works for the Mac.
    Good luck,
    xenchu

    Perl has one Great Advantage and one Great Disadvantage:

    It is easy to write a complex and powerful program in three lines of code.
Re: What could I do with just Perl?
by bradcathey (Prior) on Nov 29, 2003 at 15:41 UTC
    As a Macaroni myself, I'm curious just what version of OS X you installed, Cody_Pendant? I just upgraded to 10.3 (Panther--which I would not necessarily recommend unless you have $120 to burn) and got a nice install of 5.8.1. I did have to reinstall the DBI and DBD::mysql, with, of course, MySQL. Also, because I am HTML::Template-dependant, I had to install that.

    But as someone still new to the idea of modules (it only took me 2 years and lurking around PM to discover them), I'm wondering what modules come standard with the 5.8.1 install, besides CGI.pm and CGI::Carp.

    The only list I can find is here. If that is truly what gets installed, then I can see Cody_Pendant's point. On the positive side, I've got a lot of exploring to do. Thanks C-P for raising the question and sending me looking.

    —Brad
    "A little yeast leavens the whole dough."
      Try Fink:

      http://fink.sourceforge.net/

      Fink is a utility that helps load the latest opensource software on OS-X, including Perl 5.8.0

      They describe it as:
      " This differs from the Apple OS X 10.1 distribution of Perl 5.6.0 (and supporting fink libraries) in that it retains the perl version subdirectories in the lib tree. Without these, upgrading or downgrading Perl breaks all of the binary modules."

      I think the reference to 5.6.0 is a typographical error - it describes the Fink version as 5.8.0 elseware on the same page.

        No, it doesn't look like a typo. Mac OS X 10.1 (and 10.2, incidentally) were distributed with 5.6.0 by default. So the Fink distribution does indeed differ from the 10.1 distribution of Perl 5.6.0.

        I am amused, however, that the parent note mentioned that Mac OS X 10.3 comes with Perl 5.8.1 by default and you're suggesting using fink to install 5.8.0.

Re: What could I do with just Perl?
by Cody Pendant (Prior) on Nov 29, 2003 at 21:12 UTC

    Thank you all for your concern and help with installing.

    Perhaps I should have said that I did a manual install of Perl and everything is fine now.

    The key problem for me was that with this crippled version of Perl on OS X you get CPAN, but CPAN apparently can't install anything because of missing header files, CORE/something.h was missing? It was very annoying anyway.

    But I long ago sorted that stuff out and Perl and CPAN and fink are all working just fine thank you.

    My question was "what could I do with just Perl", not "what can I do with my crippled install of Perl", so it was really more of a philosophical question -- the things we love about Perl, that make it so useful, how many of them are in the modules and how many are in the language/application itself?



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss') =~y~b-v~a-z~s; print
Re: What could I do with just Perl?
by jonadab (Parson) on Nov 30, 2003 at 02:48 UTC

    Technically, you can do all of the same things with just pure Perl that you can do with all of the modules on CPAN installed. For that matter, technically, you could do all of the same stuff with C or assembly language, or anything else that's Turing-equivalent. (If you're not familiar with this concept, do a Google Groups search for Turing Equivalence.)

    So, why do we have CPAN then? Because in practice there's often a big difference between technically can be done and what it is suitably convenient or worthwhile to do. It is *possible* to write an email client in pure Perl with no modules, but it will take you weeks just to get a very basic working start. With POP3Client, Net::DNS, and Net::SMTP, you can have the same amount done in hours. It is *possible* to write database stuff in pure Perl to interface with an RDBMS, but with DBI you can do it in a *lot* less time. It is *possible* to study up on PKWare's Zip archive file format and write your own Perl code to read and write zipfiles, but you'll spend days or weeks; with Archive::Zip you can do it in an afternoon and have time left over for testing.

    In short, the value of CPAN is not in what it enables you to do, but in what it saves you from needing to do.


    $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      No. Turing equivalence is not enough.

      Turing equivalence allows you to compute the same things, true, but it does not allow you to _do_ the same things. For instance if you take brainf*ck, well known to be turing complete, how do you get brainf*ck to do a syscall? You can't.

      Besides the computational power you also need the "functional" power. In Unix this means that you need syscalls. If you have syscalls then you have it all. (Since I/O for instance translates into syscalls).

      On a more theoretical note you might observe that the Turing machine has an "infinite tape". So any machine that is equivalent to a turing machine will have to have infinite storage capacity.

        Turing equivalence allows you to compute the same things, true, but it does not allow you to _do_ the same things.

        Besides computation, the only other thing there is to _do_ is I/O. Whether Perl has adequate I/O without modules is going to depend I suppose on what kind of I/O you need to do, but in general if you compare it to other existing languages it fares quite well in that regard. Syscalls are not, strictly speaking, needed for anything other than I/O.

        However, I certainly agree that Turing equivalence is in itself not enough to expect out of a good language. That was actually my point, though maybe I didn't state it very clearly. If that were enough, we could all just use assembly language, or, as far as that goes, program using hexadecimal numbers directly. Having a good language is about making things more efficient, easier, better, et cetera; for Perl, part of that is the CPAN; I personally do not consider any Perl installation to be complete or terribly useful in practice without a working CPAN.pm

        There happens to be at the moment more on this topic (Turing equivalence and its inadequacy as a criterion for determining the usefulness of a language) on my pad, as I am presently in the process of piecing together there a pending meditation which may or may not end up getting posted. (Feedback on it, including whether it is worth posting, is welcome.)


        $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
Re: What could I do with just Perl?
by elwarren (Priest) on Dec 02, 2003 at 00:41 UTC
    Well, three things pop into mind while reading this.
    • SSH has been implemented in pure perl. You could do that. Your limitation is based on size, not dependency, so any module functionality you reproduce will still take up (possibly more or less) space on your system. Is an SSH client binary smaller than a gzipped ssh client script including the pure perl implementation?
    • You could think about all the things you (or others) used to do with shell scripts before they had perl. Ok, now think about how much you could improve the functionality of your code when you discovered sed, awk, or grep. Now rewrite it in perl.
    • Building on the previous item, if you had core modules like Socket you could build all kinds of marvelous tools. A web browser with simple markup (lynx), a file server that takes a filename and dumps contents back down the pipe (webserver), a multiuser chatsystem (ychat), a lush descriptive text based game (mud/bbs). I've seen all these implemented as shell scripts, they're cake in perl. They are all very simple protocols you could emulate with a telnet client, could you imagine trying to do something like this on a heavy modern protocol based on XML wrapped packets, bleh.
    You could spend time recoding your second program, the one you wrote right after Hello World:
    10 print "elwarren is cool!" 20 goto 10
    :-) The question is kind of like, what should I code next? It's all up to you and your imagination.