#!/usr/bin/perl use strict; use warnings; while () { chomp; my @col = split /;/; push @col, '' for @col .. 2; print join ';', @col; print "\n"; } __DATA__ a;3 b;2;3 c;5;4 d;6