perl question

How can I change the following using

perl -pi -e 
test.txt
--------
00:00 AM
00:00 PM
00:12 AM
11:11 PM
out.txt
-------
12:00 AM
12:00 PM
12:12 AM
11:11 PM

I have the following code which works with sed but not using perl

sed 's/00:\(.*M\)/12:\1/g'  test.txt > out.txt
perl -pe 's/^00/12/' urfile
12:00 AM
12:00 PM
12:12 AM
11:11 PM