in reply to Re: My First Perl Project
in thread My First Perl Project

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 :).

Replies are listed 'Best First'.
Re: My First Perl Project
by jonadab (Parson) on Feb 17, 2004 at 22:27 UTC

    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
      :). I can only wish to be that good :).
Re: Re: Re: My First Perl Project
by diotalevi (Canon) on Feb 17, 2004 at 19:15 UTC
    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.