#!/usr/local/bin/perl

use strict;
use warnings;

use Encode::RAD50;
use Getopt::Long;

my %opt;

my $usage = <<EOD;

Convert input to RAD50.

usage: irad50 [options]

Input is from STDIN, output to STDOUT. Valid options are:
  -help
    displays this text;
  -quiet
    supresses warnings on invalid characters;
  -uppercase
    folds input to upper case before conversion.

Copyright 2005-2007, 2011-2012 by Thomas R. Wyant, III
(F<wyant at cpan dot org>). All rights reserved.

PDP-11, RSTS-11, RSTS/E,  RSX-11, RSX-11M+, P/OS and RT-11 are
trademarks of Hewlett-Packard Development Company, L.P.

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl 5.10.0. For more details, see the full text
of the licenses in the directory LICENSES.

This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.
EOD

GetOptions (\%opt, qw{help quiet uppercase|uc}) or die $usage;
$opt{help} and do {print $usage; exit};
Encode::RAD50->silence_warnings ($opt{quiet});

binmode (STDOUT, 'encoding(rad50)');
while (<>) {
    $_ = uc $_ if $opt{uppercase};
    print
}

