Sorry I was not realising that I aksed a bit too much. I actually figured it out on my own. So i guess I leave the code here in case anyone needs it. Have a nice day!
#!/usr/bin/perl
# PERL MODULES
use strict;
use DBI;
use DBD::ODBC;
use Text::CSV;
use List::MoreUtils qw(each_array);
# SOME VARIABLES
my $file="/tmp/Stevo/clientlist.csv";
my $csv = ();
my $fh = ();
my $data_source = q/dbi:ODBC:MSSQLServer/;
my $user = q/username/;
my $password = q/password/;
# WRITE HOSTNAMES FROM CSV TO ARRAY
my @hostnames;
open (my $csv, '<', $file) || die "cant open";
foreach (<$csv>) {
chomp;
my @fields = split(/\,/);
push @hostnames, $fields[0];
}
# WRITE CLIENTVERSIONS FROM CVS ARRAY
my @clientversions;
open (my $csv, '<', $file) || die "cant open";
foreach (<$csv>) {
chomp;
my @fields = split(/\,/);
push @clientversions, $fields[1];
}
# CONNECTION STRING
my $dbh = DBI->connect($data_source, $user, $password, {RaiseError => 0, PrintError => 1}) or die "Can't connect to $data_source: $DBI::errstr";
# INSERTION CODE
my $sth_insert = $dbh->prepare('INSERT INTO dbo.LegatoClients (ClientName, ClientVersion) VALUES (?, ?)')
or die $dbh->errstr;
# EVERYTIME $EA IS CALLED THE NEXT LINE OF THE ARRAYS WILL BE RETURNED
my $ea = each_array(@hostnames, @clientversions);
# SET VALUES USING THE EVERYTIME ARRAY
while ( my ($val_hostnames, $val_clientversions) = $ea->() ) {
$sth_insert->execute($val_hostnames, $val_clientversions) or die $dbh->errstr;
}
solved Insert local .csv data in remote SQL Server via already working connection string