in reply to Beginner Question

My son, let me engage in some kindly advice. First off, as Roy Johnson pointed out I am not possessed by the Nazis, but I am a Perl Nazi. If being such means that I want to see things done correctly then I'm a Perl Nazi! If being a Nazi means that I am passionate about my chosen favorite programming/scripting language then I'm guilty as charged. However I refuse to be associated in spirit with those monsters that 50 years ago or so attempted to obliterate an entire ethnicity based on a madman's vision of humanity.

Secondly, you come to the Monestary asking for advise without consulting the Tutorials and I know this because if you had you'd realize that there is a right way and a wrong way to ask for help here at the Monastery. If you ask the wrong way don't be surprised if you have scorn heaped upon you. While I don't necessarily condone the act of heaping scorn on people, I can't help but think you brought it upon yourself.

Does how we capitilize Perl mattter?

When I see something in all capital letters I assume that it is a acronym for something else. A phrase, a compound word or whatever. It can be argued that PERL is an acronym for a lot of things. Those of us that have been around the language for a while have read or heard some of those and the two that come to mind right now are:

All that aside the proper noun version is "Perl" which refers to the language itself. The command line is "perl". Or on some systems "/usr/local/bin/perl" or whatever.

As to the originally asked question

Grasshopper, let me share with you some more wisdom. In your post you made it difficult indeed for anyone to understand what went wrong with your attempts since you did not post any code. Some of us monks may well approach omnicience (sp?) but I don't think there are any here that are omnipotent. I for one never aquired the skill of clairvoyance and cannot read your code from afar and troubleshoot it for you. It has to be posted here on PM for the world to see and so we can guide you on the path of Perl rightousness.

Also having an understanding of what went wrong can help as well. Post your error messages as well. It may well be that your code is correct, but when run there is a lack of permissions to do the work.

That being said, let's examine what you are trying to do:

Simple enough. First you need to iterate. There are many ways to do this from the simple to the extravagant but here is one such construction:

use strict; for my $dir('a'..'z') {

Now, you need to invoke one of many tools that allow you to programmatically create the named directories within your iteration. I have a favorite, but I'll keep it simple for now. Also I want to make sure I do any error checking that is available to me in order to know what went wrong if things indeed go wrong. If I consult perldoc I find that mkdir returns a value if it fails. Further it sets $! which allows me to print what happened. Finishing this thought we get:

mkdir $dir # note: perms with be 0777 # depending on the setting of umask or die "Could not create $dir: $!"; }
If the mkdir fails the code will exit and you'll have a nice error message telling you why it failed.

Now, I made a horrible assumption here. You also failed to tell me what platform your code is expected to run under or anything else about your environment. My comment about umask is valid on a *nix environment but doesn't make a hill of beans on a Evil Empire® based system.

Good luck on your journey towards Perl nirvana, careful of the pitfalls and snares along the way, and do ask questions here at PM. Just be smart about how you ask...


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg