use strict use warnings use File LibMagic wget http zhumarin ru tmp pn

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
use strict;
use warnings;
use File::LibMagic;
`wget "http://zhumarin.ru/tmp/1.png" -O "/tmp/test_libmagic.png"`;
`mv /etc/magic /etc/magic2`;
my $ft = File::LibMagic->new();
my $screen_body;
open FH, "</tmp/test_libmagic.png";
read FH, $screen_body, -s "/tmp/test_libmagic.png";
close FH;
print $ft->describe_contents(substr($screen_body, 0, 1024));
END {
`mv /etc/magic2 /etc/magic`;
}