To be more precise, it's the "axle to crown (A-C)" length you want. From the center of the hub's axle to where the headset crown sits at the bottom of the steerer tube.
Also, suspension forks compress a little just sitting on the bike; this is called sag. It's best to match the new fork's A-C to the old fork's A-C after accounting for (subtracting) the sag. As long as it is close, it's good enough. The handling will change slightly, but you'll get used to it (if you can even initially feel it).