use strict;
use warnings;
open(FILE4,"cool.txt");
open(FILE6,">./mool.txt");
$line = <FILE4>;
while ($line ne "")
{
@array = split(/,/,$line);
$line = <FILE4> ;
print FILE6 ($array[0]);
print FILE6 ("\t");
print FILE6 ($array[1]);
print FILE6 ("\t");
print FILE6 ($array[2]);
}
These is the code I have written in perl. But the code is not working fine. Its giving tab space for every nextline. But i dont need that TAB space for every new line.Let me show you how the output is.
name contact email
samy 32344245 hyte@some.com
alex 231414124 coool@some.com
This is how i see my mool.txt file.The first line its working fine.But from the nextline I’m facing tab space.I am trying to find out where the bug is.Can anyone please let me know where the code is going wrong?I have gone through it so many times but unable to figure it out.Thank you
As someone asked im showing you the input file
"name","contact","email"
"samy","32344245","hyte@some.com"
Put this statement inside the while loop.
chompThis should be the first line after reading a line from a file. This will remove unwanted spaces.