<div dir="ltr"><div class="gmail_quote">On Fri, Oct 3, 2008 at 12:39 PM, Alex Beamish <span dir="ltr"><<a href="mailto:talexb@gmail.com">talexb@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Amazingly enough, I actually used this new-found piece of knowledge<br>
today, building an array of hashrefs for a call to a library that I<br>
cannot (yet) change:<br>
<br>
my @symbols = map { +{ 'key' => $_ } } @things;<br>
<br>
Proof once again that Perl is an unbelievably powerful language. I'm<br>
glad you used it, and I asked you about it. :)<font color="#888888"><br>
</font></blockquote></div><br><br>I'm glad I used it too! Glad I can keep getting employment in Perl! I've always found these little things fun. There's apparently a whole thread of these little "Hidden Features of Perl" on StackOverflow right now:<br>
<br><a href="http://stackoverflow.com/questions/161872/hidden-features-of-perl">http://stackoverflow.com/questions/161872/hidden-features-of-perl</a><br><br>Going back, when I was interviewing for my current job with Richard, he took me out on a technical interview before I got to meet the VP ('cause if I did, I found out when the VP chatted with me, it meant I was worth actually talking to).<br>
<br>Anyhow, Richard asked me this question on the interview. Let's suppose you've got an OO module. Now, for some reason, you want an 'a' method that is really an alias for 'b'. Your assignment? Do this in the least number of characters possible without shifting the args off of @_.<br>
<br>Now, I thought I was being smart with:<br><br>sub a {<br> $_[0]->b(@_[1..$#_]);<br>}<br><br>But I'd forgotten that I didn't need the ';' because it's the last statement in the block. Stupidly, I'd forgotten that invoking with -> just stuffed the invoking blessed ref into the arg list so I could have done this:<br>
<br>sub a {<br> b(@_)<br>}<br><br>But then Richard broke my head with:<br><br>sub a {<br> &b<br>}<br><br>My jaw literally hit the table. I'd also not know the & invocation style (without brackets) automatically passed @_ into the sub. I'd thought that & is soooo Perl 4 and beneath my notice. Whoops. Two characters. Two bloody characters to my 21.<br>
<br>Got the job though. :)<br><br>-- <br><a href="mailto:dave.s.doyle@gmail.com">dave.s.doyle@gmail.com</a><br><br><br>
</div>