$<.each do |line| $> << line unless line.strip.split(",").gsub('"','').strip.empty? end
For some actual work. What else could be on my mind except golf?
¶ 4:11 PM
Comments on “Springtime Sunny Saturday”:
It's code like this that makes me wonder what the people are always complaining about with Perl being unreadable. Sure, I'm not a Ruby person but sheesh, this is no more readable than a lot of Perl code yet I never hear the bitching about Ruby syntax the way I hear about Perl syntax. I guess the benefits of being the cool new kid extend to this type of stuff as well.
Please reach over to the controls and set attitude to 'chill' :-)
This code was, in fact, a one-time throw-away shell script, not a piece of machinery embedded in an application. I personally don't care for this kind of thing, which is why I was making fun of it.
That being said, How could I use Java to filter a large CSV file by select the lines that have a value in the third column?
Hopefully, the answer would be "Use this library that hides the cruft." But were we to include the library's source, would the result be more readable somehow?
or perhaps we could include a lot of named variables. For example, STDIN and STDOUT would be much more readable than $< and $>. Unless, of course, you use Unix and use such a script with "script < infile.csv > outfile.csv," in which case $< and $> actually make some sense.
In summary, Real Programmers(tm) can write Fortran in any language. And Perl in any language. And Shell Scripts in any language.
I have no idea how I would use Java for that, despite being a Java programmer in the Real World. I would probably pretend to write it in Java and do it in Perl instead. :)
I guess lack of sleep made that comment more cranky than it was meant, sorry. You get nothing but love from me, really. The comment wasn't directed at you but at the hordes of Perl haters I have to read regularly. In other words: ignore.push('matt'). :)
Hey, I found the code to be perfectly understandable. I was just wondering whether  referred to the second or the third array member. And I have never programmed Ruby or, in fact, seen much Ruby code at all.
Then again, I haven't seen an unreadable Perl code yet. Bad Perl code, yes. But I have seen bad Java code too, and it was worse than anything I have ever seen in Perl.
I find that Perl code tends to be dense, the way that code above is. There's little redundancy, there are powerful first class types, and functional ju-ju.
So you go through 40 lines of code and feel like you have read 1000 lines of code. It's not that the code is bad or unreadable, it's just that there's actually 1000 lines of plain Java code (emphasis on "plain") worth of content in those 40 lines.
Now, I can't say I feel the same way about APL or MUMPS. :-) APL because my mind doesn't work well after the third dimension. MUMPS because it's control structures suck. I love being able to execute code I placed in a variable, for instance, but the following, frankly, sucks:
IF stuff execute A ELSE execute B
The above can well result in executing both A and B. Or could, the last time I used it.