Simple things first: It is not the message Undefined subroutine &main::ratio because we are not in package main but in a class Gear where the method is defined.