#!/usr/bin/perl use strict; use warnings; use Text::CSV; my @ports = qw(portname portID port802); my @val1 = qw(ON ON OFF); my @val2 = qw(EX EX NEX); my @records; while (@ports) { push @records, [shift @ports, shift @val1, shift @val2]; } my $csv = Text::CSV->new ({sep_char => ';'}); for my $record (@records) { if ($csv->combine (@$record)) { print $csv->string, "\n"; } else { print "combine () failed on argument: ", $csv->error_input, "\n"; } } #### portname;ON;EX portID;ON;EX port802;OFF;NEX