sub ignore_options { # remove all telnet options from incoming text # Parameter: Text my ($text) = @_; my $chIAC = chr(255); my $chDONT = chr(254); my $chDO = chr(253); my $chWONT = chr(252); my $chWILL = chr(251); my $chSB = chr(250); my $chSE = chr(240); my $chSEND = chr(1); my $chIS = chr(0); my $chEOR = chr(239); my $pos = -1; while(($pos = index($text, $chIAC, $pos)) > -1) { my $nextchar = substr($text, $pos + 1, 1); if(!length($nextchar)) { last; } if($nextchar eq $chIAC) { substr($text, $pos, 1) = ''; $pos++; } elsif($nextchar =~ /($chDONT|$chDO|$chWONT|$chWILL)/) { substr($text, $pos, 3) = ''; } elsif($nextchar eq $chSB) { my $endpos = index($text, $chSE, $pos); substr($text, $pos, $endpos - $pos + 1) = ''; } elsif($nextchar eq $chEOR) { substr($text, $pos, 2) = ''; } else { substr($text, $pos, 2) = ''; } } return $text; }