#! /usr/bin/perl use strict; use warnings; my $n_file = 'path/to/file_with_number.txt'; my $out = '/path/to/outfile.dat' my @numbers = (); my @diameters = (); # anzahl einlesen; open(R_N,"<$n_file") or die $!; my @lines_n = ; close R_N; chomp(@lines_n); for(my $i = 0; $i < $#lines_n; $i += 2){ push(@numbers,split(/ /,$lines_n[$i])); push(@diameters,split(/ /,$lines_n[$i+1])); } open(W_FILE,">$out") or die $!; for(0..$#numbers){ print $numbers[$_]," ",$diameters[$_]; } close W_FILE;