my @a=(); my @b=(); my @a1=(); my @b1=(); my @perl_array=(); my @filena = split(/\|/, $filename); open (TXT, "<$filename") || die "Can't open $filename: $!\n"; while (my $line=) { chomp($line); ($a2, $b2) = split /,/, $line; push @a,('"',"$a2",'"',','); push @b,('"',"$b2",'"',','); } splice @a,0,4; #this splice is used to remove the header name. i.e. first row data- secid, Initial_shares splice @b,0,4; push @a1,"var secid=[@a]"; push @b1,"var Initial_shares=[@b]"; push @perl_array, "@a1; @b1"; close TXT;