OT: Another perl question

Chris Pressey cpressey at catseye.mine.nu
Sun Jan 18 16:30:23 PST 2004


On Sun, 18 Jan 2004 15:55:42 -0800
Gary Kline <kline at thought.org> wrote:

> 	
> 	Is there an easy way of determining "file - determine file type"
> 	in perl? at least as certain as magic(5) can ascertain?
> 
> 	E.g:
> 
> 	if (($ftype = file ($ARV[i])) eq "script){
> 		## do abc;
> 	}
> 	else if ($ftype eq "Mail"){
> 		## do def;
> 	}
> 	else if ($type eq "C program"){
> 		## do xyz;
> 	}
> 	.
> 	.
> 	.
> 
> 	I've been poking around perl tutorial sites; so far, nada.
> 	Thought I'd ask the wizards.
> 
> 	thanks for any clues,
> 
> 	gary

How about /usr/ports/devel/p5-File-MMagic ?

"This module is to guess file type from its contents like file(1)
command."

-Chris


More information about the freebsd-questions mailing list