Ali Barber, the carpet merchant, has a rectangular piece of carpet whose dimensions are unknown. Unfortunately, his tape measure is broken and he has no other measuring instruments. However, he finds that if he lays it flat on the floor of either of his storerooms, then each corner of the carpet touches a different wall of that room. He knows that the sides of the carpet are integral numbers of feet and that his two storerooms have the same (unknown) length, but widths of 38 feet and 50 feet respectively. What are the carpet dimensions?
1. **Understanding the problem**: We need to find the dimensions of a rectangular carpet that fits perfectly in two different storerooms, each with the same length \(L\) but different widths \(a = 50\) feet and \(b = 38\) feet. The carpet touches all four walls in each room, meaning each corner of the carpet touches a different wall.

2. **Setting up the equations**: Let the dimensions of the carpet be \(x\) and \(y\). When the carpet is laid in a room of dimensions \(L \times a\), the following conditions must hold:
   \[
   L = x \cos(\theta) + y \sin(\theta)
   \]
   \[
   a = x \sin(\theta) + y \cos(\theta)
   \]
   Similarly, for the room of dimensions \(L \times b\):
   \[
   L = x \cos(\phi) + y \sin(\phi)
   \]
   \[
   b = x \sin(\phi) + y \cos(\phi)
   \]

3. **Deriving the condition**: From the above equations, we can derive:
   \[
   \cos(\theta) = \frac{xL - ay}{x^2 - y^2}
   \]
   \[
   \sin(\theta) = \frac{yL - ax}{y^2 - x^2}
   \]
   Squaring and adding these, we get:
   \[
   (xL - ay)^2 + (yL - ax)^2 = (x^2 - y^2)^2
   \]
   This simplifies to:
   \[
   (x^2 + y^2)(L^2 + a^2) - 4aLxy = (x^2 - y^2)^2
   \]

4. **Setting up the system of equations**: We have two such equations for the two rooms:
   \[
   (x^2 + y^2)(L^2 + 50^2) - 4 \cdot 50 \cdot L \cdot xy = (x^2 - y^2)^2
   \]
   \[
   (x^2 + y^2)(L^2 + 38^2) - 4 \cdot 38 \cdot L \cdot xy = (x^2 - y^2)^2
   \]

5. **Subtracting the equations**: Subtracting these two equations, we get:
   \[
   (x^2 + y^2)(50^2 - 38^2) = 4Lxy(50 - 38)
   \]
   Simplifying, we find:
   \[
   (x^2 + y^2)(2500 - 1444) = 48Lxy
   \]
   \[
   (x^2 + y^2) \cdot 1056 = 48Lxy
   \]
   \[
   L = \frac{22(x^2 + y^2)}{xy}
   \]

6. **Substituting \(L\) back**: Substituting \(L\) back into one of the original equations:
   \[
   (x^2 + y^2) \left( \frac{22(x^2 + y^2)}{xy} \right)^2 + 2500 - 4 \cdot 50 \cdot \frac{22(x^2 + y^2)}{xy} \cdot xy = (x^2 - y^2)^2
   \]
   Simplifying, we get:
   \[
   (x^2 + y^2) \left( \frac{484(x^2 + y^2)^2}{x^2 y^2} \right) + 2500 - 4400 = (x^2 - y^2)^2
   \]
   \[
   (x^2 + y^2) \left( \frac{484(x^2 + y^2)^2}{x^2 y^2} \right) - 1900 = (x^2 - y^2)^2
   \]

7. **Simplifying further**: Let \(x = pu\) and \(y = pv\) with \(\gcd(x, y) = p\) and \(\gcd(u, v) = 1\). The equation becomes:
   \[
   (u^2 + v^2) \left( \frac{484(u^2 + v^2)^2}{u^2 v^2} \right) - 1900 = 16p^2u^2v^2((u^2 + v^2)^2 - 4u^2v^2)
   \]

8. **Finding integer solutions**: We need \(uv\) to divide \(88\) (since \(a + b = 88\)). Possible pairs \((u, v)\) are \((2, 1), (4, 1), (8, 1), (11, 1), (22, 1), (44, 1), (88, 1), (11, 2), (11, 4), (11, 8)\).

9. **Checking pairs**: Only \((2, 1)\) gives a perfect square for \(p^2\):
   \[
   p^2 = 625 \implies p = 25
   \]
   Thus, \(x = 50\) and \(y = 25\).

10. **Verifying the solution**: Check if \(L = 55\) fits:
   \[
   L = \frac{22(50^2 + 25^2)}{50 \cdot 25} = 55
   \]
   This satisfies the conditions.

The final answer is \(\boxed{(50, 25)}\).