ClearAll["Global`*"];

Manipulate[
Block[
{m, b, eta, y, Y, f, L},
m = 1;
b = 0;
L = 1;
eta[x_] := Sin[Pi x / L];
y[x_] := m x + b;
Y[x_] := y[x] + epsilon*eta[x];
f[x_, Y_, Yprime_] := Sqrt[1+Yprime^2];
Show[

Plot[Y[x], {x, 0, L}],
Plot[y[x], {x, 0, L}, PlotStyle->Red],
Graphics[
Text[Style[
"Length = "<> ToString[NIntegrate[f[x, Y[x], Y'[x]], {x, 0, L}]],
{Large, Bold}], {0.5, 0.8}]
],
Graphics[
Text[Style[
"epsilon = "<> ToString[epsilon],
{Large, Bold}], {0.5, 0.95}]
]
]
],
{{epsilon, 0}, -0.5, 0.5}
]

ClearAll["Global`*"];

pathlength[epsilon_] := 
Block[
{m, b, eta, y, Y, f, L},
m = 1;
b = 0;
L = 1;
eta[x_] := Sin[Pi x / L];
y[x_] := m x + b;
Y[x_] := y[x] + epsilon*eta[x];
f[x_, Y_, Yprime_] := Sqrt[1+Yprime^2];
NIntegrate[f[x, Y[x], Y'[x]], {x, 0, L}]
];
Plot[pathlength[ϵ],{ϵ,-0.1,0.1}]