xjlittle has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have been learning perl for the last month or so. Having gone through several tutorials writing practice code I decided it was time to try one of my own.

Following is some code that works for removing emacs tmp files and core files generated by the kernel from the /home/john and /lib directories. One of my goals for this is to easily change which directories are parsed.

My question is on the way I setup the parameters to be passed to the subroutine. Is this the correct way to setup multiple arguments for the subroutine?
#!/usr/bin/perl -w $user = "/home/john"; $lib = "/lib"; &directs($lib); &directs($user); sub directs { foreach (@_) { opendir(DIRS,$_); @tmps = readdir(DIRS); closedir(DIRS); } &remove; } sub remove { foreach $line(@tmps) { if (($line =~ /~$/ ) || ($line =~ /^core\./)) { unlink "$line"; #print "$line\n"; } } }

All of these are really good answers. I will start implementing (or learning how to use them) immediately.

One of the reasons that I made this post is to learn the correct way and get into the habit of doing things that way. Fortunately I don't have any bad habits to break since I have never programmed before-I am a network administrator by profession. All of you have supplied me with good habits to get into.

Thank you very much!