Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: testing for a zip file

by esh (Pilgrim)
on Aug 29, 2003 at 14:30 UTC ( [id://287671]=note: print w/replies, xml ) Need Help??


in reply to testing for a zip file

Check out File::Type

#!/usr/bin/perl -w use strict; use File::Type; my $filename = 'myfile.zip'; my $filetype = File::Type->new(); my $type = $filetype->checktype_filename($filename); my $zipped = ($type eq 'application/zip'); print "$filename is of type $type (", $zipped ? '' : 'not ', "zipped)\ +n";

When you say "zipped" do you mean "compressed" or do you mean that a specific compression algorithm/tool was used (i.e., Windows PKZIP format)?

File::Type can also tell you if the file is compressed in other ways, though you'll have to check the return value for each type.

-- Eric Hammond

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://287671]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-23 07:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found