my @col = qw(RECORD SUBSCRIPT ID_SUBSTN CO_SUBSTN AREA_SUBSTN ID_DEVTYP ID_DEVICE NAME_DEVICE AREA_DEVICE ID_MEAS ID_POINT SITE_POINT AREA_POINT); my $cols = join ",",@col; # Create connection string to database point.csv (output file from scadaexport.pl) my $dbh = DBI->connect ("dbi:CSV:", undef, undef, { f_encoding => "utf-8", }); # Define and Execute SQL to select INTELI and AUTO points my $sth = $dbh->prepare ("select $cols from point.csv where ID_DEVTYP like 'INTELI%' AND ID_POINT like 'AUTO%'"); $sth->execute;