Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Language or string templates?

by Prior Nacre V (Hermit)
on Oct 02, 2004 at 04:12 UTC ( [id://395822]=note: print w/replies, xml ) Need Help??


in reply to Language or string templates?

Here's a fairly straightforward solution framework that may be suitable for your application.

Create a text/language file with this format:

. . . strCliDeactivated => 'Currently not active', strNotActive => 'date has not yet been reached', strExpired => 'date has been reached', . . .

Then in your main code, slurp in the whole file and create a hash which can then be used when required.

. . . my @global_data = <TEXT_LANG>; my %globals; eval "\%globals = ( @global_data )"; . . . print STDERR $globals{strExpired} if $expired; . . .

Update: Sorry, I had two solutions in my head - I posted half of each. I've added two lines to the main code replacing:

my %globals = ( @global_data );

Apologies for any confusion.

Regards,

PN5

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://395822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-24 02:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found