I wrote some code (about 100 lines) that is working fine on version 5.12.1. Unfortunately my client is using version 5.10.0. So I tested the code on 5.10.0 and found it doesn't work!
Where can I find a list of differences between 5.10 and 5.12?
Edit:
I think the best answer to the question of "Where can I find a list of differences between 5.10 and 5.12" is plusplus' comment under the "accepted answer". For the explanation of the code below, please read Michael Carman's answer.
The code that works on 5.12.1 but does not work on 5.10.0 ($contents
is still an empty string after running the code)
# read in the first 10 lines.
my $contents = '';
for (my $i = 0; $i < 10 && ! eof; $i++) {
$contents .= <FILE>;
}
The improved code that works on both versions.
# read in the first 10 lines.
my $contents = '';
my $i = 0;
while (<FILE>) {
last if $i >= 10;
$contents .= $_;
$i++;
}