Hi,
I'm facign a strange problem in reading a text file.
The contents of my text file is:
A1;B1;C1;D1
A2;B2;C2;D2
A3;B3;C3;D3
i want to split the contents based on the ";" (semi-colon).
I use the following code for it:
Im getting the following output:
--------------------------------
A1
B1
C1
D1
DONE!
---------------------------------
What surprises me, is why the remaining contents of $data is not stored in the "$values" array.
Another Question: if i try to split $data like this:
then, the output is:
------------------------------
A1;B1;C1;D1
DONE!
------------------------------
Can any1 tell me what could be the reason for the text after D1 not being displayed in both the cases.
Any help is appreciated.
Thanks,
Ravi
I'm facign a strange problem in reading a text file.
The contents of my text file is:
A1;B1;C1;D1
A2;B2;C2;D2
A3;B3;C3;D3
i want to split the contents based on the ";" (semi-colon).
I use the following code for it:
Code:
open (OUT, "report.txt") || die "Can't open the File $!\n"; my $data = <OUT>; my @values = split ";", $data; my $num = 0; while($num < 12) { print $values[$num++]; print "<br>"; } close(OUT); print "DONE!";
--------------------------------
A1
B1
C1
D1
DONE!
---------------------------------
What surprises me, is why the remaining contents of $data is not stored in the "$values" array.
Another Question: if i try to split $data like this:
Code:
my @values = split "\n", $data;
------------------------------
A1;B1;C1;D1
DONE!
------------------------------
Can any1 tell me what could be the reason for the text after D1 not being displayed in both the cases.
Any help is appreciated.
Thanks,
Ravi
Comment