Intersect will cut your rail polylines with the polygons. You will still need to select the polylines that fall within each polygon, and total their length. Once they are intersected, you could do a spatial join to associate the sub basins with the rail lines, so you can do a summary on the basin ID, returning the sum of rail line lengths.
Regards,
Jim