From: Peter J. Holzer on
On 2010-06-10 02:59, Peng Yu <pengyu.ut(a)> wrote:
> According to Programming Perl, more than one way may not always be
> better. But I just don't see more than one way is better at all.
> I think that any code can be encapsulated in a subroutine or a class.
> To the end user, the actually implementation doesn't matter.

No, but it does matter to the programmer. Programming languages are
there for the programmer, not the user. Somebody will have to write and
maintain that subroutine and it is important that this person can
express the function of the subroutine in a natural way. Otherwise we
could just have stuck with machine language.


From: Peter J. Holzer on
On 2010-06-11 09:55, Peng Yu <pengyu.ut(a)> wrote:
> On Jun 10, 10:14�am, Charlton Wilbur <cwil...(a)> wrote:
>> >>>>> "PY" == Peng Yu <pengyu...(a)> writes:
>> � � PY> In this sense, there were a subroutine that can read multiple
>> � � PY> lines from a file. There is no need that the users should
>> � � PY> understand the different ways of reading muliple lines as
>> � � PY> discussed in other thread mentioned the original post.
>> Ah, but the reason there are multiple ways to do things is because the
>> choice of which way to do things depends on the context.
>> The best way to read *three* lines from a file is not the best way to
>> read *ten thousand* lines from a file. �Instead of mandating one way,
>> the Perl philosophy is to assume that you're a competent programmer who
>> can judge the quality of various solutions for yourself.
> Rather than being hypothetically saying there are different ways of
> coding for different parameter values. I'd like to see what the best
> code is for reading three lines and what is the best code is for
> reading 10000 lines?

Three lines I would just slurp into memory. I would probably do the same
for 10000 lines. But for 10000000 lines, I would process them line by
line, keeping only the information absolutely needed.

Then it depends on the frequency of the task. If I have a piece of code
which needs to read the same file pretty frequently (say about once per
second) and the file might change at random moments, then:

* for a 3 line file I would just read the file every time
* for a 10000 line file I would check whether the file has actually
changed before reading it again.

Oh, and this is almost independent of the language. TIMTOWTDI in every


From: Peter J. Holzer on
On 2010-06-11 18:21, Christian Winter <thepoet_nospam(a)> wrote:
> I'd say the same is true for Perl. Its power lies in the fact
> that it gives the possibility to work one step closer to the
> machine than with other competing languages like e.g. Java, C#
> or PHP.

For me Java is a lot closer to the machine then Perl.