Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Language or string templates?

by Prior Nacre V (Hermit)
on Oct 02, 2004 at 04:12 UTC ( #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? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2022-05-23 12:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?