?

Log in

No account? Create an account
IBNeko's Journal-Nyo~!
ibneko
ibneko
Oh, and would anyone happen to know...
...what the heck the \ before the variables mean in perl...?

LJ::do_request(\%req, \%res, $flags);

[ edit | 11:10 ]
ah, nevermind, I found it on google.. had to search for "slash before" and perl though. Apparently it's Dereferencing. WTF??? =.= Why the holy flying fuck would you even want to do that? Now, I suppose the memory location would be useful.. but WHY is livejournal calling that when you do post? Why is it sending do_request() the memory location of those hashes (any perl variable that starts with the % is a hash, perl variables that start with @ are arrays, and $ are scalars) instead of the actual value.

I don't comprehend the madness. Fuckit, that's irritating me. Now I need to spend time reading the de_request function. Buggers.

...yeah, I know there was more cursing there than usual, but it irritates me that that wasn't covered in "Learning Perl" ¬.¬ stupid book and stupid llamas.

Current Mood: productive productive
Current Music: Winds_nocturne-remix

4 happy kittens | Leave catnip
Comments
andr00 From: andr00 Date: January 23rd, 2004 12:55 pm (UTC) (Link)
Because if you send perl a bunch of arrays as an argument to a function call, the argument list gets flattened into a big list of scalars, with no way to tell where the various arrays started and ended. That includes associative arrays.

sending those hash references allows the code in the function to refer to the hashes as if they could be passed whole as discrete arguments.

You probably already found the real answer to your question, but trying to explain things that you think you know is a good way to discover the holes in your knowledge, if you're honest. So I try to do it whenever possible.
ibneko From: ibneko Date: January 23rd, 2004 04:21 pm (UTC) (Link)
Oooh, ok. ::nods:: I knew it was sending it by reference, but it didn't seem like it was being handled in any particularily special manner in the function, and that confused me.

(looking back at the code, I guess it was... they use -> (ie. $req->{'event'})... should have noticed that and made a connection... instead of $req{'event'})

btw, do you know of any good perl books that you can recommend? I'm reading Learning Perl from O'Reilly right now, but it covers a lot of the basic stuff that I've already picked up from writing a perl based AIM bot to post on my livejournal server and a perl script to open and read files and post them online.... and Learning Perl moves a bit too slowly for me...
andr00 From: andr00 Date: January 26th, 2004 05:19 am (UTC) (Link)
I read the blue O'Reilly "Perl" book ('the camel book') from cover to cover, and made up little exercises and things for myself so I'd remember what was in it. Read that one! Read the whole thing!
ibneko From: ibneko Date: January 26th, 2004 05:38 am (UTC) (Link)
Oh, the camel book, okey. ::has the llama book at the moment... the shortened camel?::
4 happy kittens | Leave catnip