my $stmt = "SELECT filename FROM tabelle"; my $sth = $dbh->prepare($stmt) or die $dbh->errstr(); $sth->execute() or die $dbh->errstr(); while(my ($text) = $sth->fetchrow_array()){ print get_MD5($text); } sub get_MD5 { my ($text) = @_; my $md5=Digest::MD5->new; $md5->add($text); return $md5->hexdigest(); }