use strict; # split request into head:filename sub splithead($) { my $req = shift; my ($head, $fname, $replace); if (index($req, ":") > 0) { $req =~ /^([^:]*):(.*)$/; $head = $1; $fname = $2; } else { $head = ""; $fname = $req; } if ($head =~ /^@/) { $replace = 1; } else { $replace = 0; } return ($head, $fname, $replace); } # ascii to petscii sub atopet($) { my $string = shift; $string =~ tr/a-zA-Z_/A-Za-z\xaf/; return $string; } # petscii to ascii sub pettoa($) { my $string = shift; $string =~ tr# a-z A-Z \xc1-\xda \xaf \xef \xff \xe0-\xee \xf0-\xfe # A-Z a-z \x41-\x5a _ _ \x7e \xa0-\xae \xb0-\xbe#; return $string; } # return the lowest of two numbers sub min($$) { my $a = shift; my $b = shift; if ($a < $b) { return($a); } else { return($b); } } # sleep for n seconds, where n is a float sub fsleep($) { my $secs = shift; select(undef,undef,undef,$secs); return(undef); } # print debug output sub debug($) { my $message = shift; print $message if $::debug; } # print safe ascii sub pretty($) { my $in = shift; my $out = ""; foreach (split(//, $in)) { if (ord($_) == 10 || ord($_) == 13 || ord($_) >= 32 && ord($_) <= 126) { $out .= $_; } else { $out .= " \$" . unpack("H2", $_) . " "; } } return($out); } return(1);