Is it possible to use the ++ operator inside a string interpolation? I've attempted the following:
my $i = 0;
foreach my $line (@lines) {
print "${i++}. $line\n";
}
but I get Compile error: Can't modify constant item in postincrement (++)
printf():printf("%d. %s\n", $i++, $line);print "@{[ $i++ ] }. $line\n"(it's similar to @dgw's one, which has been written while I was editing this comment)