[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Book & script



"Kevin Reid said:"
> 
> > Having been a programmer for 28 years, it never ceases to distress
> > me how little maturity is shown by most modern programming languages.
> > In several instances during the writing of my archive script, I
> > was uncertain how to implement a construct in Perl, so I tried what
> > looked like the "obvious" way.  I'm not talking about "if-else" or
> > parameter passing, either, but rather complex stuff involving file
> > handles and split functions.  Astonishingly (to this cynic), my
> > guesses were correct every time.  To me, this means that someone
> > went to a lot of trouble designing the language and its parser so
> > that they act sensibly. (duh!).
> 
> Perhaps you could provide some details?
> 
> I'm curious about the exact situations where the "obvious" thing worked
> when you thought it might not.

It wasn't that I didn't expect it to work -- rather, that I knew what
I wanted, but wasn't sure MacPerl would "know".  E.g., I didn't have
a feel for how it would read in a file I was using to index my directory
(I wanted to read a line, separate it into line number and content, and
put those values into separate variables) so I tried what I thought I wanted:

while (<FH>) {
    ($index, $fpath) = split(/ /, $_, 2);
    blah, blah, blah...
}

And it did exacty what I wanted.  Generally in other languages you
have to be exquisitely careful when doing stuff like this, or else you
get garbage.  Perl did exactly what I wanted.  Like I said, Larry and
Matthias did their homework. :-)


-- 
| Greg Dunn                       | Every year is getting shorter,    |
| GregDunn@aol.com                | never seem to find the time       |
| gregdunn@indy.net               | Plans that either come to nought  |
| GregDunn@compuserve.com         | or half a page of scribbled lines |
| http://members.aol.com/gregdunn |                  Pink Floyd       |

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch