Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: file(1) equivalent?

by mr.nick (Chaplain)
on Jan 11, 2012 at 21:12 UTC ( [id://947431] : note . print w/replies, xml ) Need Help??


in reply to file(1) equivalent?

I think the OP is looking for a callable function from inside his/her own scripts. The linked CPAN link isn't a module, but an external program.

Which really confuses me ... why write a command-line utility that mimics another (other than for fun-n-profit)?

However, OP, you can always wrap the functionality of that script up into a function of your own to use. Though I'm a bit surprised one doesn't already exist (I didn't search).

Edit: How about File::Type?

mr.nick ...

Replies are listed 'Best First'.
Re^2: file(1) equivalent?
by Eliya (Vicar) on Jan 11, 2012 at 21:26 UTC
    why write a command-line utility that mimics another

    It is part of the "Perl Power Tools" / Unix Reconstruction Project — for which the README says

    "Our goal is quite simply to reimplement the classic Unix command set in pure Perl, and to have as much fun as we can doing so."

    (discontinued by now, AFAIK)

      Ha! I had totally forgotten about that project. Looks like it went dead between 2004 & 2006.

      Oh, duh the original link even had "ppt" in it and I didn't notice. Funny thing is if you go to the top level page for the project, the module I linked (File::Type) is listed there.

      mr.nick ...

        PPT was a project for which most work was done long before 2004. 1997 or 1998, IIRC. Before the first YAPC.
Re^2: file(1) equivalent?
by ikegami (Patriarch) on Jan 12, 2012 at 00:17 UTC

    Which really confuses me ... why write a command-line utility that mimics another (other than for fun-n-profit)?

    Portability is a common reason. e.g. ExtUtils::MakeMaker reimplements some unix tools in Perl for this reason.