my @printernames = qw( foo bar ); my @ipaddresses = qw( 1 2 ); sub combine { my $name_ref = shift; my $addr_ref = shift; if ( @{$name_ref} != @{$addr_ref} ) { die "given arrays are not of equal size.\n"; } for my $i ( 0 .. $#$name_ref ) { printf "%s;%s\n", $name_ref->[$i], $addr_ref->[$i]; } } combine( \@printernames, \@ipaddresses );