Perl Smack Down
Today I was working on a problem related to Hashtables in C#. I basically needed to be able to get a key based on a value. My friend "pudge" wrote the following in perl:
@keys = grep { $hash{$_} eq 'Perl' } keys %hash;
I wrote something similar in C#:
public string GrepHashForKey(Hashtable ha, string search){ foreach(object o in ha.Keys){ if(ha[o].ToString().Equals(search)) return o.ToString(); } return ""; }
I have got to spend more time with perl. When programmers speak of a sexy language, this is what they mean. There are a few languages I'd like to be fluent in before my technie days are over: LISP, Perl and Python.
8:06:07 PM
|