It's great you're using
use strict and have warnings enabled; otherwise perl would never warn you about errors like this. The problem you're encountering is that when
strict is enabled, perl requires that you declare your variables (
$line and
@lines, here) before using them. The simplest way is with the
my keyword. Check out that link for more info. Other ways to declare variables include
use vars and
local, though
my is the usual method for situations like yours. A quick fix might go like this:
#!/opt/perl5/bin/perl -w
use strict;
my ($line, @lines);
while($line=<> and $line ne ".\n"){
push @lines,$line;
}
foreach(reverse @lines){
print;
}