perlbrew command syntax:
perlbrew <command> [options] [arguments]
switch Permanently use the specified perl as default
~$ perlbrew help switch
Usage: perlbrew switch [ <name> ]
Switch to the given version, and makes it the default for this and all
future terminal sessions.
Without a parameter, shows the version of perl currently selected.
You just need to issue your command in a Terminal window:
$ perlbrew switch perl-5.14.2
Then if you do:
$ perlbrew list
...you will see something like:
* indicates the default perl.
I'm not sure why your command doesn't work in .bashrc--although the command only needs to be issued once, so putting it .bashrc isn't appropriate anyway. According to this article, Terminal does not execute .bashrc--instead it executes .bash_profile for all shells, so maybe that's why it doesn't work. According to that article, if you want to execute .bashrc, you have to enter some code in .bash_profile to do so.
Another possibility: you spelled your perl's name wrong. To check the spelling, do:
$ perlbrew list
...then copy and paste the name of the perl that you want to be the default into your switch command.
The way perlbrew works is that it adds the path to a certain perl version onto the front of your PATH environment variable. As you probably know, when you issue a command in a Terminal window, like
perl, your OS looks for the command in the directories specified in the PATH environment variable--in the order the directories are specified. As soon as the command is found, your OS stops searching. First match wins!
When the Terminal window closes, perlbrew then removes the path from the front of your PATH environment variable. However, when you use the
switch command (v. the
use command), perlbrew neglects to remove the path from the front of your PATH environment variable. Therefore, the next time you open a Terminal window and issue the
perl command, the command will be found in the first directory specified in your PATH environment variable, which will be the directory for the perl version that you set with the perlbrew