I am trying to learn perl programming and am using it to read a file from a contest;
#!/usr/local/bin/perl
use warnings;
open(FILE, <~/source/test.txt>);
@array = <FILE>;
$number = shift @array;
while($number--) {
chomp($key = shift @array);
chomp($message = shift @array);
print "Key: $key";
print "Message: $message";
}
print "\n";
close(FILE);
The file contains a number, N, then there are 2 * N lines that follow which is how many key/message pair's there are.
But when I do this program, it only prints out the last "message" and nothing else... it doesn't print anything else. If I remove the chomps it works as intended, but with the chomps there it just cuts everything off... any ideas why?
//EDIT: removed the -w