Uhm... I wouldn't say that anything is wrong! Its just the last entry in the file (that appears to be comma delimited, going by your split statment) will have a \n on the end. If you input file takes the form of
then your code will produce
Code:
name1@domain.com\nname2\n@domain.com\n
which is gonna look like
Code:
name1@domain.com
name2
@domain.com
Try chomping the line so your code will look something like
Code:
#!/usr/local/bin/perl -w
$file = '/directory/of/file/xxx';
open(INFO,$file);
$lines = (<INFO>);
close(INFO);
$add = "\@kym.edu.my";
@line = split(/,/,$lines);
foreach $name (@line) {
chomp($name);
print "$name$add\n";
}
You always want to run Perl with
-w that way it will give you lots of useful messages about potential problems.
HTH
Jamie...