Menu

1 / 2

Context::Vars: Perl variables with context scope

DEV Community: perl·LNATION·25 days ago
#hEU4u6bR
#devtoperl#devto#dev#context#vars
Reading 0:00
15s threshold

Context::Vars is another new CPAN distribution I've published which solves a familiar problem in Perl programs. Some values belong to one request or one job: a request id, the current user, a tracing span. Code far down the call stack needs to read them, and so do callbacks that run later. Sometimes they need to be overriden within specific context.

The usual answers each fail in a different way. A global gets overwritten as soon as two requests are in flight on one event loop. local is undone when the sub returns, which is before a callback registered in it ever runs.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.