in reply to Determine target file format looking at one link

File::MMagic
#!/usr/bin/perl -- use strict; use warnings; my $file = 'test.png' ; # must exist my $fileL = 'test.link'; # will be created/removed checkit( $file ); warn 'Linking ', link( $file, $fileL ); checkit( $fileL ); warn 'UnLinking ', unlink( $fileL ); sub checkit { use File::MMagic; my $mm = new File::MMagic; # use internal magic file print "Checking $_[0] => ", $mm->checktype_filename( $_[0]),$/; } __END__ Checking test.png => image/png Linking 1 at file.mmagic.check.pl line 12. Checking test.link => image/png UnLinking 1 at file.mmagic.check.pl line 16.