Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

What's in a Name?

by schumi (Hermit)
on May 29, 2002 at 09:32 UTC ( #170011=perlmeditation: print w/replies, xml ) Need Help??

Inspired by this thread I was wondering whether fellow monks follow any conventions when choosing names for programmes and scripts.

I tend to use telling names for programmes and scripts which are operative, like for a script which lets people order books; and names which rank from silly to plain non-sense to sometimes outright foul when writing wee test scripts whose life-span is expected to be anything below an hour.

Of course, sometimes these test scripts survive and actually get to be operative themselves, and as long as it's only me handling those scripts that is ok. But no (user|website visitor) should have to see a call for a script named, hrmpf.cgi or any such.

And what happens, when someone else has to work with those scripts, say another webmaster, or even a job successor? Names like, are not exactly helpful to find out what the thing does. But then, sometimes names can be very obvious for the person creating the script, while not at all for others.

How do yous handle this?


There are nights when the wolves are silent and only the moon howls. - George Carlin

Replies are listed 'Best First'.
Re: What's in a Name?
by Abigail-II (Bishop) on May 29, 2002 at 10:17 UTC
    First, I'd like to say something about the extension. There's a tendency to have Perl programs end in '.pl'. Why is that? We type 'ls', 'mutt' and 'netscape', not 'ls.exe', 'mutt.exe' or 'netscape.exe'. Why would you want to type '' to execute the tool? That requires users to remember in which language a tool is written. If you later replace the tool by a better version, this time written in Python, will users be pleased if they now have to type ''?

    I use '.pl' for files I'm still working on. But as soon as they escape from their development directory, and are place in a directory that might be in someones PATH, the '.pl' gets dropped.

    Names should, IMO, be descriptive. "" might be cute, and I can guess that it's dealing with books, but not that it actually orders books. If it orders books, I'd call it "orderbooks" or "order_books". No ".pl" - the language in which it's written should not matter for the results. I don't really care if a name is long. We don't live in the early 70s anymore, nowadays we have shells with filename and command completion, and we have aliases too.

    Now, for scripts I only use once, or just to test things out, I usually use '', '', '', and other one letter combinations. And more than 90% of the time, they will be placed in '/tmp'.


      Let's talk about Windows first:
      First if it's not a CGI, but a command line utility it is necessary to give those files an extension. The only other solution would be to force the users to use a Unix shell. That's be even harder on most of them.
      Second ... the fact that you do not have to enter the .exe should lead to a question "Is it possible to set the system so that you do not have to type .pl?" And of course it is. You just have to add that extension to the list in PATHEXT system variable. Easy to do in a network login script or something, isn't it?

      So then the script files do end with .pl, but everybody may call them without.

      Then CGIs under Windows:
      if you use Apache you do not need the extensions, if you use IIS you do. In either case it's not such a big problem to make a redirect there somewhere so that both addresses work.

      For Unix:
      yeah you are right that there the extensions are not needed. I find that way of handling files a bit crazy, but that's another point.


      Many times I find using a pl extension convienent. I use probably about 90% of the time. For utils I don't use it. Then again most of my programs are run on my servers and not by end users.


      "To be civilized is to deny one's nature."
      I do agree with you as long as we're talking about user-called scripts. However, webservers tend to insist on extensions.

      As far as why I'm using extensions for non-web scripts, I do admit that this is mainly a habit - I'm still mostly working on windoze.


      There are nights when the wolves are silent and only the moon howls. - George Carlin

        However, webservers tend to insist on extensions.

        That's just a matter of configuration.


        Even if they do, .pl has no reason to be. Call them .cgi if necessary. It may sound silly, but there's no reason to be telling anyone what language your scripts are written in.

        Makeshifts last the longest.

OT: What's in a Name?
by jplindstrom (Monsignor) on May 29, 2002 at 20:32 UTC
    I wrote a script called (no Perl at all :( ) which is used to watch disk space, database segments, processes, etc. etc.

    After six months we discovered that it, sometimes on some machines, crashed after being run for a measly three, four weeks. So I also made the script create another guard process, watching . So who watches the watcher(1)?

    Custos Custodio.

    I think things like that is important.


    (1) That would be "Quis ipsos custos custodes?" in Latin.

Re: What's in a Name?
by perrin (Chancellor) on May 29, 2002 at 15:22 UTC
    Um, I would have named it "order_books", at least if it's a command-line script. I fully agree with Abigail's statement about leaving off the .pl.

    For web-based applications, I don't need to follow silly Win32 conventions about file-naming because I use mod_perl. I have modules like MySite/Controller/ and tie them to URLs like /books/order/, or whatever the marketing folks like the look of.

Re: What's in a Name?
by FoxtrotUniform (Prior) on May 29, 2002 at 15:44 UTC

    Naming conventions:

    • At work, anything that gets called by machine gets a .pl extension. (At home, the shebang line is identifier enough -- and .pl collides with my Prolog stuff, anyhow.)
    • Trivial test scripts are usually named foo, bar, etc.
    • I tend to follow Unix conventions when naming scripts: mktmpl instead of make_template, for instance. Fits better with my thinking patterns.

    The hell with paco, vote for Erudil!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://170011]
Approved by broquaint
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2022-01-17 04:36 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (51 votes). Check out past polls.