jducoeur: (Default)
[personal profile] jducoeur
May I just say, Perl is a bloody weird language?

Every couple of years I come across a project that requires some significant Perl hacking, and I brush it off. This time, I'm fiddling around in UseModWiki, to make it do what I want as a LARP-development environment. For the most part, that's entirely straightforward. But figuring out the appropriate syntax for dealing with my key data structure (a hash of hashes of arrays) is really mind-bogglingly tricky. I spent a good two hours just figuring out how to get things to dereference into the proper contexts, so that I stopped getting things like "ARRAY (0xabfoobar)" in my data files.

(Is there actually any documentation on the @{ } and %{ } operators? They're referred to all over the Perl docs, but I couldn't find anything actually telling me outright how you're supposed to use them, so I had to do a lot of trial-and-error experimentation.)

Oh, I'm sure that by the time I'm done, I'll have gotten my fluency back. But man -- after spending the past two years working primarily in C# and The Horror That Men Call ActionScript, Perl does require bending my brain into a pretzel...

(no subject)

Date: 2004-08-13 10:52 am (UTC)
From: [identity profile] goldsquare.livejournal.com
eval is your friend. (:-)

Bloody Weird Language

Date: 2004-08-13 10:55 am (UTC)
From: [identity profile] dagonell.livejournal.com
What I detest most about Perl is that it doesn't preserve array structures. First of all, you can't have a two dimentional array, it's all one long list, okay that I can deal with.

But if I establish Flintstones = [Fred, Wilma, Pebbles, Dino]
and Rubbles = [Barney, Betty, BammBamm, Hoppy] and then pass them into a function "families (Flintstones, Rubbles)" and ask for array lengths, Flintstones has 8 members and Rubbles is empty! That drove me mad!!!!
-- Dagonell

Re: Bloody Weird Language

Date: 2004-08-13 11:06 am (UTC)
From: [identity profile] cahwyguy.livejournal.com
I think that is an artifact of the passing mechanism, which pulls everything into a single array for the purposes of passing information (none of this silly type stuff). It then unpacks the array from @ARGS (I may have the name wrong), which is why they recommend you put the scalars first, then the arrays. The solution to your problem is to use join and split to make the arrays into scalars and vice-versa upon return.

Re: Bloody Weird Language

Date: 2004-08-13 11:47 am (UTC)
mindways: (Default)
From: [personal profile] mindways
Unless I'm grievously miremembering...if you're using Perl 5, you can simply pass the function a reference to each of the two arrays. (Since references are scalars.)

(no subject)

Date: 2004-08-13 11:03 am (UTC)
From: [identity profile] cahwyguy.livejournal.com
Perl was bloody wierd from day 1, and I'm the only person that can truly say that, as Larry, Mark (Perl's maternal uncle) and I (Perl's paternal godparent) were sharing an office at the time of creation. I was the first user, combining perl with the use of Qmenu, a system I had from my days at Quadratron.

I think it has only gotten wierder over time. I still pretty much limit myself to Perl 4 constructs; the rest still boggle the mind (and I'm actually worried about Perl 6).

Profile

jducoeur: (Default)
jducoeur

October 2025

S M T W T F S
   12 34
567891011
12131415161718
19202122232425
262728293031 

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags