in reply to ls piped tpo perl -pe runs indefintely

The second one modifies @ARGV, the first one doesn't. Due to you use of -n (why?), the first one executes the body for every line of the files listed by ls. It should actually terminate, but if you have a lot of large files, this my take a while.

The second one intends to do the same, that is, execute the body for each of the lines of the files listed by ls, but here you are actually modifying @ARGV, which causes the implicit <ARGV> to terminate after the first iteration.

My guess is that if you remove the -n, both will do what you want them to do.