foreach(@Array){ $line = shift(@Array); # Read the next line to line-Parameter $Ext = $1 if($line =~/EXTENSIONNUM=(\d+)/); # Extract the Extension-Number $ExtName = $1 if(($line =~ /NAME=(\d+)/)||($line =~ /NAME=(\w+)(\d+)/)); $allocDate = $1 if ($line =~ /DATEALLOCATED=(\d+-\d+-\d+)/); $AccountID = $1 if ($line =~ /ACCOUNTID=(\d+)/); push(@Array3,$ExtName," ",$Ext," ",$AccountID," ",$allocDate,"\n"); push(@Array4,$Ext,"\n"); }