I have been using this script of mine FOREVER and I have always been using \"~/\" to expand my home directory. I get into work today and it stopped working:
#if
As stated by prior answer, "~" (tilde) is expanded by shell, not perl.
Most likely, it was working due to existence of a directory "~" in your current directory, which eventually got removed, leading to the bug surfacing:
To illustrate:
Tilde not working in Perl, using $ENV{HOME} works:
$ echo MM > MM
$ perl5.8 -e '{print `cat ~/MM`}'
cat: cannot open ~/MM
$ perl5.8 -e '{print `cat $ENV{HOME}/MM`}'
MM
Making the tilde-named directory works:
$ mkdir \~
$ echo MM > \~/MM
$ ls -l \~
-rw-rw-r-- 1 DVK users 3 Jun 10 15:15 MM
$ perl5.8 -e '{print `cat ~/MM`}'
MM
Removing it restores the error, as you observed:
$ /bin/rm -r \~
$ ls -l \~
~: No such file or directory
$ perl5.8 -e '{print `cat ~/MM`}'
cat: cannot open ~/MM
This offers a plausible explanation, though I'm not 100% there can't be others.