gl_LightSource[0].position.xyz in modern OpenGL

I’m a beginner. I noticed in old code

// Calculate the light position for this vertex
vec3 vertex_light_position = gl_LightSource[0].position.xyz;

I assume that’s dynamically changing and hence can’t test it with simply a static vec3.

How do I go with replacing the above in modern OpenGL? An example would be greatly appreciated.

You need to supply your own uniforms instead of relying upon built-in ones. Exactly what you need depends upon your own requirement - anything goes!
The advantage of your own system is that lighting calculations can be in world space or lightspace - ie before multiplying with the modelview matrix