How to open a file from the end and read the last 100 lines

J

James Willmore

"I" was not told. I am not the original poster.

Sorry. Didn't mean to offend.
There is no problem using it. I am pretty sure it does it's work
pretty well. And I was not talking about this special case.

If you need the script to work without installing other 20 modules
from CPAN, this will do.

I disagree. I also think that your statement about "20 modules" is a
bit extreme. If I were to read into this, I'd say you're using a
dialup connection and are frustrated about the fact that you have a
hard time maintaining Perl and all the modules. I could be wrong.

I have seen some modules that have quite a few dependencies. Most of
them (the dependencies) were core Perl modules. When the core Perl
modules go out of date, it's time to upgrade Perl. It's like that
*everywhere*. When you see apps failing to install on a Linux system
- and they fail because of an outdated kernel version, it's time to
upgrade the kernel - and *all* the applications that are dependent
upon the kernel (like iptables). Granted, this example is Linux, but
it illustrates the fact that it's not just Perl, it's a lot of other
software/hardware/etc out there.
I was talking about the principle of checking CPAN for trivial
problems. Don't get me wrong, this may not be a trivial problem if
you have to run this script on GB or TB of data, several times a
minute/second. But if you run it once a day/week on some MB, should
be ok.

No - read on ...
The main think is productivity and what I am advocating is
"balance." Sometimes is faster/better your own, sometimes some CPAN
module. Decide when to go for one or the other is the difficult
part.

Again, I disagree. Why spend the extra time to find out that someone
else has already figured out what you need to do - and has *tested*
it. Sounds like you speak out of frustration and not anything
practical.

Let's look at something that's been posted *many* times here - the
famous "I can't use sendmail to send email in my script" example.
This issue would be moot if the person would just use one of the
*many* email modules available. Now you don't have to worry about
*what* the system you're using uses to send email. In fact, you could
use a system without *any* email server. Our NTP server at work uses
.... a Perl script ... to send email. No email services are on the
system at all. It uses a module to do this.

I suppose you *could* code using sockets and a whole lot of other
basic idioms of code to accomplish this. But you could *never* be
quite sure you have tested the code enough. Or that it would work
after, say, a system upgrade. With modules, this issue is reduced,
even eliminated, because the maintainers would take the time to apply
the appropriate fixes to the code. You just upgrade and, in most
cases, problem solved *before* you even know there's a problem :)

But, if you feel the need to "roll your own", then you're entitled to
do so :)

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
"Nuclear war would really set back cable." -- Ted Turner
 
M

Mihai N.

I am afraid this is going way too far.
Did you ever wasted several hours with a module that was buggy,
or just not good enough for what you needed?

But this is not about this.
I was just trying to tell that there is something in between
"always rool your own" and "always use CPAN".
What bothers me is the "always" part.
I think there is no such thing as black or white, there is always
about gray levels, and any extreme is bad.

I would not try to write my own sendmail, db, or ftp routines
(in fact I do have quite a few scripts using modules developed by
others).

Where is the balance? I don't know. I guess it is not the same
for all (it would be borring). Even for me the line is moving.
If I am in a hurry, if I want to learn something new, if I'm tired.
Right now I'm tired of this discution. Sorry.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top