Obsoleting require 'Some/Module.pm'

2005-12-19 Thread Gaal Yahas
Can we make this work?

 my $mod = Some::Module;
 require $mod;

It's a very simple patch to pugs. While we're at it, does anybody see a
compelling reason to leave in the Perl 5 semantics of require $file?

We could follow the heuristic of the very sane Module::Load, and try
*either* a file *or* a module, but I'm wondering if it isn't a good time
to clean up how we look at modules of code and say that anything loaded
via use or require is named Perlishly only. %*INC keys would thus be
uniformly Perlish names, and their values can be an interesting
structure containing the relative and actual absolute path of the
resources loaded. (In fact, this is what recent pugs does :).

I know some code does require 'foo.ini', but can't that be relegated
to a module and use a different store than %*INC?

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


Re: Obsoleting require 'Some/Module.pm'

2005-12-19 Thread Darren Duncan

At 2:58 PM +0200 12/19/05, Gaal Yahas wrote:

Can we make this work?

 my $mod = Some::Module;
 require $mod;

It's a very simple patch to pugs. While we're at it, does anybody see a
compelling reason to leave in the Perl 5 semantics of require $file?

snip

I would very much appreciate such a feature myself, since I always or 
primarily use Perlish names when loading modules.  With such a 
change, I would be able to say:


require $module_name;

... and have it DWIM, which in my mind is the same as require Foo;, 
and I would no longer have to say:


eval require $module_name;;
die if $!;

... as I do now.

I like to save string evals for when I'm actually using arbitrary 
runtime generated Perl code which is in a variable.


-- Darren Duncan


Re: Obsoleting require 'Some/Module.pm'

2005-12-19 Thread Sam Vilain
On Mon, 2005-12-19 at 14:58 +0200, Gaal Yahas wrote:
 Can we make this work?
 
  my $mod = Some::Module;
  require $mod;

What about casting it to a package;

  require ::{$mod};

(not sure if the syntax is quite right)

Sam.