View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Colin Faber > File-Scan-ClamAV-1.06 > File::Scan::ClamAV



Annotate this POD


Open  2
View/Report Bugs
Module Version: 1.06   Source   Latest Release: File-Scan-ClamAV-1.95


File::Scan::ClamAV - Connect to a local Clam Anti-Virus clamd service and send commands


 my $av = new File::Scan::ClamAV;
        my %found = $av->scan('/tmp');
        for my $file (keys %found){
                print "Found virus: $found{$file} in $file\n";


This module provides a simplified perl interface onto a local clam anti-virus scanner, allowing you to do fast virus scans on files on your local hard drive, or streamed data.



Create a new File::Scan::ClamAV object. By default tries to connect to a local unix domain socket at /tmp/clamd. Options are passed in as key/value pairs.

Available Options:


Pings the clamd to check it is alive. Returns true if it is alive, false if it is dead. Note that it is still possible for a race condition to occur between your test for ping() and any call to scan(). See below for more details.

On error nothing is returned and the errstr() error handler is set.


Scan a directory or a file. Note that the resource must be readable by the user the ClamdAV clamd service is running as.

Returns a hash of filename => virusname mappings.

On error nothing is returned and the errstr() error handler is set. If no virus is found nothing will be returned and the errstr() error handle won't be set.


Same as scan(), but does not scan inside of archives.


Preform a scan on a stream of data for viruses with the ClamAV clamd module.

Returns a list of two arguments: the first being the response which will be 'OK' or 'FOUND' the second being the virus found - if a virus is found.

On failure it sets the errstr() error handler.


Sends the QUIT message to clamd, causing it to cleanly exit.

This may or may not work, I think due to bugs in clamd's C code (it does not waitpid after a child exit, so you get zombies). However it seems to be fine on BSD derived operating systems (i.e. it's just broken under Linux). -ms

The test file t/03quit.t will currently wait 5 seconds before trying a kill -9 to get rid of the process. You may have to do something similar on Linux, or just don't use this method to kill Clamd - use kill `cat /path/to/` instead which seems to work fine. -ms


Cause ClamAV clamd service to reload its virus database.


Return the last error message.


Colin Faber <> All Rights Reserved.

Originally based on the Clamd module authored by Matt Sergeant.


This is free software and may be used and distribute under terms of perl itself.

syntax highlighting: