in reply to how to expand home directory ~

"~" is expanded by the shell, not by perl:
> perl -e'print @ARGV' ~joost /home/joost

Note that ~/madam is usually NOT /home/madam, but /home/madam/madam (unless your home directory is /home). You probably want ~madam (or just plain "~", which is the current user's home dir).