No, you cannot include perl code like that and have it set variables any more, and there are better ways to solve that.
To keep it simple, I like just using a plain text file for languages, for example have one english.txt with
MSGID = message text
e.g.
ENTER_EMAIL = Please enter your email address
and have equivalent file for other languages.
Then, use something like
sub read_language_file {
my $file = shift;
die 'language file ' . $file . ' does not exist :(' . "\n" unless(-e $file);
my %language = ();
open(LANG, '<', $file) || die $!;
while(my $line = <LANG>) {
$line =~ s/\s+$//gs; # kill all whitespaces at the end of each line
next if(substr($line, 0, 1) eq '#' || $line eq ''); # allows to uncomment lines by putting # in the beginning
my ($key, $value) = split(/\s*=\s*/, $line, 2); # will match MSGID = text, MSGID=text etc
$language{$key} = $value;
}
close(LANG);
return %language;
}
in your code, call the function with a filename and it will return a language-hash.
my %text = read_language_file("english.txt");
print $text{"ENTER_EMAIL"};
That's a pretty basic way of dealing with that. Of course, it has weaknesses, for example it doesn't support placeholders, you cannot easily add singular/plural forms.
If you want to do that, look at
Locale::Maketext [search.cpan.org] (
great article about what it does and why [search.cpan.org])