I recently started learning perl, I switched to Linux and realized that I had a perl interpreter and decided to put it to some good use. Anyway, it occured to me how much more cool Linux is than Windows becuase I could not make Windows run a perl interpreter, as a matter of fact my first big project to test my skills is to rebuild DOS using perl :). So far I have it using echo, cd, and dir :).

Replies are listed 'Best First'.
Re: My First Perl Project
by flyingmoose (Priest) on Feb 16, 2004 at 18:01 UTC
    FYI, Windows can absolutely have Perl (and for free) -- ActiveState.com -- however, it's well known that Linux is much better for software development, welcome aboard.

    It may be a great learning experience (and I hope that is why you are doing it), but you do realize you are cloning the world's most crippled shell interface, right? Ugh, DOS. If only it were dead...

    FYI, here is Micro$oft's proposed DOS replacement: MONAD (Google search)

Re: My First Perl Project
by simonm (Vicar) on Feb 16, 2004 at 21:11 UTC
    it occured to me how much more cool Linux is than Windows becuase I could not make Windows run a perl interpreter

    On the other hand, many people find downloading the ActiveState distribution to be easier than installing Linux...

    I'm glad you're enthusiastic, but in the future I'd suggest that you refrain from bashing an OS on the basis that you couldn't accomplish something that tens of thousands of others have -- it makes you look like a clumsy novice.

    (Of course, there are plenty of plausible reasons to bash Windows, but lack of a convenient Perl installation isn't one of them.)

Re: My First Perl Project
by nite_man (Deacon) on Feb 17, 2004 at 11:12 UTC

    It's great that you've chosen Linux (I did it two years ago. At first, I couldn't work efficient :)) but now I'm satisfied with using Linux). But, of course, you can develop your project under Windows without any problems. You can install Perl, Apache, mod_perl, Embperl, Mason etc the same as under Linux.

    Also, you can install and use Cygwin - Linux emulation for Windows.

    Hope it will be helpful for you.

    ~ Schiller

Re: My First Perl Project
by jonadab (Parson) on Feb 17, 2004 at 14:47 UTC
    I recently started learning perl, I switched to Linux and realized that I had a perl interpreter and decided to put it to some good use.

    Good idea. Putting Perl to good use is not only fun, it's also a great way to learn stuff.

    Anyway, it occured to me how much more cool Linux is than Windows becuase I could not make Windows run a perl interpreter

    Most Linux distros come with Perl out of the box, as does any other decent modern operating system these days, but it's available for Windows, and in fact I learned Perl on a Windows 95 system at first. You have your choice of ActiveState Perl, which has better Windows integration, or Cygwin, which is a complete POSIX environment. Which one is better depends on whether you want to use Perl for doing Windows stuff like interfacing with MS Office (in that case, choose ActivePerl) or for running Perl code that was really written for *nix (in that case, you want Cygwin). Of course, if you're on a Linux-based system then you just use the Perl that came with your distribution usually. It's also generally easier to get CPAN working on Linux than under Windows (though it's possible with Cygwin).

    my first big project to test my skills is to rebuild DOS using perl

    All of DOS, or just the command interpreter?


    ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print
      Well, I was just cloning the command line. I have a brother that uses Windows, but does not have the courage to learn how to use DOS because he's afraid that he might mess somehting up, so I figured that if I simulate the DOS command line I could teach him, and possibly other people, the value of being able to work with command line. I know that he would be safe working with a perl script on my computer, so when he's ready he could play with the DOS on his computer :).

        Ah, that makes sense. Of course, the usual way to solve this problem is with an unprivileged user account, but if your brother uses Windows 9x/Me then that option is out, since it doesn't have such things.

        (Windows XP, being based on NT, does have the ability to create unprivileged user accounts, and while it's possible for a malicious and knowledgeable person to shatter (ahem) the barriers and get localsystem privileges from an unprivileged account, that's not something that would happen by accident, so it would be a safe sandbox for your brother to use to avoid inadvertently screwing up his system. If he has Windows XP, you could set him up an unprivileged/limited account and let him use that account to play with the command prompt.)

        The real value, though, of a project like the one you're doing is in what it will teach you. It's a good project from that standpoint, because it will lead you through a number of different types of common programming issues. In fact, I would say that a command interpreter is a *particularly* good beginner project, because it easily breaks down into parts, and no one part is terribly difficult, but the overall project is quite involved and has a lot of parts. Also, you'll be able to test each part as you complete it, which is good. It'll teach you to code in a modular fashion, too, as you find that you need to abstract out things like wildcard matching, which various commands use. Overall, it's a very good project.

        I once wrote my own fake "DOS" interpreter in GWBASIC, which I used as part of a practical joke. I created a phony antivirus package called Fool Proof AV, which would pretend to scan your hard drive for viruses, print scary warning messages about what it had found, then pretend it was reformatting your hard drive. Then it presented a nice "Finished" screen saying that in order to protect you, Fool Proof had reformatted your drive and installed an older version of DOS (1.7 as I recall; there is no such version, of course) that was now in the public domain (again, this is bogus, but almost believable), and you should carefully install any software you wanted to use, making sure it was virus-free first. Then it dumped you into my fake "DOS prompt", where DIR would show about three files in the root directory, plus one DOS directory containing a dozen more files, and nothing else.

        So then I took it to my friend Andy, who didn't have any virus protection (which on a college campus circa 1994 was slightly dangerous). "Hey, Andy, I got this shareware antivirus thing. It didn't find anything on my computer. Want to try it out?" Then I stood over his shoulder and watched him run it. Great fun. It was hard to keep an earnest, straight face when he said, "What does this mean, Fool Proof has reformatted?" (He knew very well what it _meant_, of course. But you could hear in his voice he was having a little trouble assimilating the information. I muttered something to the effect that it hadn't done that on my computer. Then about ten very long seconds later something clicked in his head: "Doh, okay, you got me."

        Writing a command interpreter in Perl should be much easier than writing it in BASIC, incidentally.


        ;$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$;[-1]->();print
        Eh. While the project sounds like a lot of work for not a lot of benefit, if you learn some things along the way then it's stil la good thng.