perlmeditation
brian_d_foy
<p>
Do you have a list of things that you find odd about Perl? I'm not talking
about what you don't like, but things that just don't seem to fit in, as
if they were exceptions to normal Perl thinking.
</p>
<p>
Since Perl draws from so many other things, it's going to be a mish-mash of
things. Perl can't very well help that libc functions do things a certain
ways, or that it wanted to bridge a couple of languages. Still, there are
things that make we wonder. What makes you think "Huh?" Here's three of mine:
</p>
<h3>-M, -A, and -C units</h3>
<p>
The -M, -A, and -C file test operators return the file modification,
access, and creation times in days since the start of the program. Why?
Why why why? Does anyone actually use the values for anything other than
to compare them to each other?
</p>
<h3>mkdir() and rmdir()</h3>
<p>
The libc mkdir(),
chmod(), chown(), rmdir(), and unlink() functions take the
file name first, and so do Perl's mkdir() and rmdir(). However,
the Perl versions of the other functions take lists of
files to affect. Perl's mkdir() and rmdir() doesn't. I always
want to put the directory names second in mkdir().
</p>
<code>
int mkdir(const char *path, mode_t mode);
int rmdir(const char *path);
int chmod(const char *path, mode_t mode);
int chown(const char *path, uid_t owner, gid_t group);
int unlink(const char *path);
</code>
<p>
The Perl chown() and chmod() functions take the file names last, which
is a good thing so they can affect a lot of files. To me, mkdir() breaks
the rule because it's the only thing that doesn't take a list of names.
</p>
<h3>print FH @list</h3>
<p>
You don't put a comma between the filehandle name and the list
you give to print. I've just always thought that was odd, and I
go out of my way to point it out to people in Perl classes. I don't
have a problem with this while I code, but I still think it's an
odd corner of syntax.
</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-366986">
-- <br />
brian d foy <bdfoy@cpan.org>
</div></div>