in reply to How to accept ARG from PIPE or STDIN?

How about just
@lines = <>;
Your second example is not reading from STDIN, by the way. You probably meant this:
$ perl thiscode.pl < SOMEFILE.txt

Update: Your first example, using the pipe, is reading from STDIN.. but the magic diamond <> works for both named arguments (files listed) and STDIN.