#!/usr/bin/perl -w use strict; my ($ID, $DP, $LN, $FN, $NM); open(EMPLOYEES,") { if(/(.*):(1.*):(.*):(.*):(.*)/) { #Supposed to parse $_ $ID = $1; $DP = $2; $LN = $3; $FN = $4; $NM = $5; print $ID; # print $DP; # print $LN; # So I can see if a value is there print $FN; # print $NM; # chomp; (my @f = split(/:/)) == 5 or next; print join("\t", @f[2, 3, 0, 4]), "\n"; } } close(EMPLOYEES)