Skip Menu |

This queue is for tickets about the Constant-FromGlobal CPAN distribution.

Report information
The Basics
Id: 76050
Status: resolved
Priority: 0/
Queue: Constant-FromGlobal

People
Owner: Nobody in particular
Requestors: burak [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.01
Fixed in: 0.02



Subject: Don't prefix package in the module is loaded from main
Hi, $ TEST=42 booking-perl -wle 'use Constant::FromGlobal TEST => { env => 1, default => 11 }; print TEST' 11 $ MAIN_TEST=42 booking-perl -wle 'use Constant::FromGlobal TEST => { env => 1, default => 11 }; print TEST' 42 Prefixing package seems awkward/unnatural to me if it's called from main (lets say inside a .pl file) So, instead of: sub var_name { my ( $class, %args ) = @_; join "::", @args{qw(package name)}; } How about this?: sub var_name { my ( $class, %args ) = @_; my($pkg, $name) = @args{qw(package name)}; join "::", ( $pkg eq 'main' ? () : $pkg ), $name; }
Subject: Re: [rt.cpan.org #76050] Don't prefix package in the module is loaded from main
Date: Mon, 26 Mar 2012 16:08:40 +0200
To: bug-Constant-FromGlobal [...] rt.cpan.org
From: Florian Ragwitz <rafl [...] debian.org>
"Burak Gursoy via RT" <bug-Constant-FromGlobal@rt.cpan.org> writes: Show quoted text
> Prefixing package seems awkward/unnatural to me > if it's called from main (lets say inside a .pl file)
Agreed. I'd be happy to apply a well tested patch to make this less awkward. The repository for this module is at https://github.com/nothingmuch/constant-fromglobal In the tests, please be sure to cover all the corner cases of different package names actually boiling down to the same package and multiple different packages claiming their name is "main", "::", etc.
Download (untitled)
application/pgp-signature 197b

Message body not shown because it is not plain text.