Dear all,
I have encountered some problem here. I prompt the user for input and store it into a data file, eg. key in name and marks so the data file will look like this
andrew 80
ben 75
and the next input is carine 90. So the problem here is i want to print out carine with an asterik which will look like this.
*carine 90
andrew 80
ben 75
and the next new input is david 50 then it will look like this
carine 90
andrew 80
ben 75
*david 50
is there anyway i could achieve this?
I am doing this
print "\nPlease enter your name and marks :";
open (OUTFILE, ">>report");
$name = <STDIN>;
$mark = <STDIN>;
chomp ($name);
chomp ($mark);
print OUTFILE
$abc = ("^$name\t$mark\n");
chomp ($abc);
close (OUTFILE);
and the printing out file is like this
open (abc, "report") || die "Error opening data file: $!";
while (<abc>) {
push @array, [ split ];
foreach $list1 (@array) {
foreach $list2 (@{$list1}) {
print "'*'$list2\t";
}
print "\n";
}
Somehow this print out every element with *
Sorry for the messy code. And thank you in advance for any advice.