#!/usr/bin/perl # We need the Base64, encode_base64 function exactly use MIME::Base64 qw(encode_base64); use strict; sub process_stdin{ while(){ chomp($_); print encode_base64("$_"); } return 0; } sub process_arguments{ foreach my $cad (@ARGV){ print encode_base64("$cad"); } return 0; } ###### # main ###### my $numargs = $#ARGV + 1; if (( $numargs == 0 ) or ( $numargs == 1 and $ARGV[0] eq "-")) { process_stdin; }else{ process_arguments; } exit 0;