$/ tells readline or <> to read the whole file. foreach does not read anything, it just iterates a list. You give it a one member list: it contains the whole file as its only member.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Comment on Re^3: How to perform single operation to each line in file