in reply to untarring number of files

What your doing here is essentially a shell script with a Perl wrapping. I can appreciate that in the beginning you might be tempted to do this. But if this is what your going to do you may as well leave Perl out of it. If you have an immeadiate, one time need to untar a group of files you may be better off just using shell, but if you truly want to use Perl because it's called for then think about the best practices to implement your needs. Perl is a great tool for doing all kinds of programming, whether it's a system task or database system or whatever but you shouldn't go out of your way to do it in Perl, especially if your going to just do `` and system calls. In this example that's already been pointed out you could use Archive::Tar and that would be usefull if your application was doing more than just untaring, and certainly if this is a practice script to get your feet wet with Perl it's a good way to go. But if your really just trying to get your work done I'd suggest using the most pratical tool for the job. Perl one-liners, shell scripts, c, c++ whatever is best. You might be able to get a screw out using a circular saw but it may be a little overkill.

Good luck and come back often as you move up the learning curve. The Perlmonks is a great resource!

Replies are listed 'Best First'.
Re: Re: untarring number of files
by agentv (Friar) on Oct 23, 2003 at 22:06 UTC
    ...I don't get the "why use Perl for this" attitude. Did anyone consider that this might have been an extract from a much larger Perl program?

    And there's no good reason *not* to use Perl for this. Frankly, using Perl is just about the same as using a shell script. An interpreter must be invoked. And although Perl may weigh more than the chosen shell for a script, it's not much heavier.

    Not to mention, as someone else pointed out, that if you solve it with a Perl script, you can take that to a number of other platforms.

    ...All the world looks like -well- all the world, when your hammer is Perl.
    ---v

Re: Re: untarring number of files
by coreolyn (Parson) on Oct 23, 2003 at 18:09 UTC

    I disagree with considering "Perl wrapping" as over-engineering. In my expirience if I have 2 or 3 lines of command line tasks that I do regularly I find it quite convenient to 'wrap' them in Perl. Why Perl you may ask? Primarily to avoid shell differences. I have found many of these full blown 3 line Perl scripts ( complete with -w and use strict ) often grow in functionality and are huge time savers. More often than not the fact that I can jump on a server and complete these task in one command does more for my image than the real 'meaty' tasks I accomplish. Additionaly I can easily add on some of my home brew modules that take care of cross-platform issues ( Like ls vrs dir and / vrs \ ). I also get the added bonus of keeping my Perl coding speed and familiarity brushed up.