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