Perl: constant & require

У меня есть файл конфигурации (config.pl) с моими константами:

#!/usr/bin/perl
use strict;
use warnings;
use Net::Domain qw(hostname hostfqdn hostdomain domainname);

use constant URL => "http://".domainname()."/";
use constant CGIBIN => URL."cgi-bin/";
use constant CSS => URL."html/css/";
use constant RESSOURCES => URL."html/ressources/";
...

И я хотел бы использовать эти константы в index.pl, поэтому index .pl начинается с:

#!/usr/bin/perl -w
use strict;
use CGI;
require "config.pl";

как использовать URL, CGI ... в index.pl?
Спасибо,
Пока


ИЗМЕНИТЬ
Я нашел решение:
config.pm

#!/usr/bin/perl
package Config;
use strict;
use warnings;
use Net::Domain qw(hostname hostfqdn hostdomain domainname);

use constant URL => "http://".domainname()."/";
use constant CGIBIN => URL."cgi-bin/";
1;

index.pl

BEGIN {
    require "config.pm";
}
print Config::URL;

End

5
задан eouti 11 May 2011 в 14:04
поделиться