Slope of line l (this line is parallel to y-axis) = 1/0.
Slope of line m (this line is parallel to x-axis) = 0.
Line m is perpendicular to line l.
Now, since line 'l' is perpendicular to line 'm'
Therefore, slope of line l × slope of line m = -1.
This implies, 1/0 × 0 = -1
As per wikipedia
"Two lines are parallel if and only if their slopes are equal and they are not the same line (coincident) or if they both are vertical and therefore both have undefined slopes. Two lines are perpendicular if the product of their slopes is −1 or one has a slope of 0 (a horizontal line) and the other has an undefined slope (a vertical line)."
So, it is obvious that the rule of multiplication of slopes is not applied when one of the line is vertical and another horizontal. Further, y-axis (or more specifically, the line x = 0) doesn't have a slope of infinity but it is undefined.