Clasic Perl code from ymp