It was thus said that the Great Earle Martin once stated:
> The software that I hate the most is often the software I have to do
> maintenance on.
I'll agree to that 100%.
> I'm a 100% Perl guy, and spend a lot of time with
> other people's Perl. One of my pet hates is seeing this:
>
> > for ($i = 1 ; $i < scalar(@ARGV) ; $i++)
> > {
> > open INPUT,$ARGV[i];
>
> Perl is not C. Yes, it lets you write do this. But you shouldn't. Why?
> Because it has useful constructs like "foreach" that let you avoid
> hateful neolithic code like this.
Yes, I know that. What I did not know (until it bit me) was that @ARGV
does *not* contain the program name.
I'm primarily a C programmer. So ..
int main(int argc,char *argv[]) { ... }
/* or char **argv */
and guess what? argv[0] contains the program name, while the rest of the
command line appear starting at argv[1].
So I see that this Perl language has an array @ARGV. I don't care for the
program name, so that means:
shift @ARGV; # or is it pop @ARGV ?
foreach $argument (@ARGV) { ... }
or the for() loop. Since I'm already used to using for(), that's what I
used. Little did I realize that Perl has conviently stripped the first
argument for me (the program name).
But *neolithic code*?
What? I should do
map
{
open INPUT $_;
&do_some_process;
close INPUT;
} @ARGV;
So, am I wrong in trying to apply previous programming experience to Perl?
> > &do_some_process(INPUT);
>
> Just as hateful, or even more so, is something like this, which
> generally indicates the author hasn't read any books about Perl that
> were published since 1998, or learnt Perl from a shoddy website, last
> updated around 2001, whose author hasn't read any books about Perl
> that were published since 1998.
Odd. I have O'Reilly's "Perl in a Nutshell" book (latest version) since I
already know how to program in an imperative langauge thank you very much
and all I really *care* to know is how to declare variables, call
subroutines and pass data back and forth, and what functions are available
to me.
Guess I was wrong in that.
-spc (Back to C for me ... )