In addition to the Regex suggestion - I'd suggest avoiding the @lines altogether.
Instead of "push @lines, $line (Storing it), why don't you call convert_to_ttf($line) at that point - this way, you can avoid the store .. and .. process .
Similarly, instead of storing @converted lines, then printing them, do that at the same place - so your code looks like:
open my $fh ... etc
while (<>) {
$line .= $_;
if (is_complete_line($line)) {
print $fh convert_to_ttf ($line);
$line = '';
}
}
close $fh;
What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
-Larry Wall, 1992