Easy or even Possible? file I/O + user input

Tor Hildrum <[email protected]>
Newsgroups gmane.comp.lang.perl.golf
Message-ID <[email protected]>
A challenge was posted on a forum I frequent, and
when trying to golf down my solution I came across
something of a conundrom.

The challenge is simple:
Take a filename and a word on the commandline
or stdin and print the number of occurences the word
has in the file.

Now, I don't want to use open() or @ARGV, because
that's bad form(?), ie long.

Well, my final solution, that isn't really a solution was:
-0ne '@a=/WORD/g;print int@a'

Now, this isn't really a solution because it has the WORD
hardcoded. But, how would I be able to get the WORD
when using -n? I'm guessing this isn't possible.

So, how would one get the 2 values from the command-line
or stdin without spending so much code on open() and ARGV?

Tor
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.