Skip to main content


If you've a background in #C and #Perl and have thought about contributing to the Perl core, you know it's daunting hacking on the core of a language.

@leonerd is offering to help you learn.

nntp.perl.org/group/perl.perl5…

Also, he's written a tutorial on how to contribute a core feature: leonerds-code.blogspot.com/202…

This entry was edited (1 year ago)

Mark Gardner reshared this.

in reply to Curtis "Ovid" Poe (he/him)

I’m starting on the ${^NAME} variables one. Looking at the XS implementation of the English vars in English::Name for a starting point.
in reply to Equinox Deschanel

@equinox_deschanel That's not the best place to start. You want to just extend the list of names already present in core perl's `gv.c`
in reply to Paul Evans

That is where I’ve started; stumbling over the proper aliasing of the variables in what I’ve tried so far, so I was looking at that for hints. (I can create the new vars fine, they’re just not properly hooked up to the original magic. I think I have to have something like the table in that module to properly create the real magic variable first then add the alias at creation.)
in reply to Paul Evans

I think I've got the right hook, let me know if this seems right.

mg.c has Perl_magic_get (line 883 of mg.c) to associate the magic with the variable by looking at the string in mg->mg_ptr (this names the magic).

So if I can set the mg_ptr to (say) $., then $ARBITRARY_VAR acts like $. does, because Perl_magic_get finds the appropriate magic.

If this was a greenfield project, I'd just change the sv_magic API to let me pass an optional extra parameter to set the mg_ptr, but that has a lot of knock-on issues all over the code that expects the API to work the way it does now, so the right thing is probably to have the English vars go to magicalize the way the "real" magic vars do now to set up magic as usual, and then override the mg_ptr with the proper string after.

Let me know if this looks sensible, or if I'm way off track. Thanks!

Unknown parent

mastodon - Link to source
Füsilier Breitlinger
@sergiotarxz That's probably your best option. Perl development is strongly mailing list based.
Unknown parent

mastodon - Link to source
Paul Evans
@sergiotarxz Not at all - you could email me directly, or talk here, or IRC or send me a carrier pigeon.. or anything really ;)
in reply to Curtis "Ovid" Poe (he/him)

The single most useful phrase you can use on yourself when looking at the perl core is "ah, it's only code, how hard can it be?"