#!/usr/bin/perl use DBI; use strict; use warnings; ## Set up connection to csv data file as a database my $dbh = DBI->connect("dbi:CSV:f_dir=./", "", "", {AutoCommit => 1, RaiseError => 1}); my $sth = $dbh->prepare("SELECT AVG(col2 + col3) FROM mydata.csv"); $sth->execute(); my $value = $sth->fetchrow_array; foreach (@value){ print $_."\n"; } $sth->finish(); $dbh->disconnect();