The sudo makes me think you're using ubuntu. If so, then you're much better off using ubuntu's packages rather than CPAN. E.g., sudo apt-get install libtest-www-mechanize-perl. CPAN and apt don't know about each other, and you can get yourself all tied up in knots by trying to mix the two. E.g., bad stuff can happen when your system upgrades to a newer version of perl.