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 [EMAIL PROTECTED]'
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