my $line = 1; while (){ my $class = ($line % 2) == 0 ? "even" : "odd"; print qq{\t\t\t}; # rest of the loop here $line++; }