UPDATE:

Looks like i didn't read your question well. My original post isn't really a solution to the problem at hand . . .

What you need is a template! You could actually use HTML::Template for this, or roll your own if it is minor enough. I do recommend delimiting your TAG though, maybe enclose USER in brackets [], or just do what tye says. But you will have to substitute your value in.

ORIGINAL POST FOLLOWS:


Oh no! Not the dreaded no strict refs!!

Seriously, do a Super Search on symbolic references and you will see why that are bad, bad, bad.

How about an XML solution instead?

use strict; use XML::Simple; local $/; my $xml = XMLin(<DATA>, forcearray => 1); foreach (@{$xml->{'user'}}) { print "the user is $_\n"; } __DATA__ <users> <user>jeffa</user> <user>foo</user> <user>bar</user> </users>
If you have XML::Simple installed, you can run this without a hitch. Next step would be to remove the __DATA__ section and place it in your config file. Then you can worry about $ENV{'USER'}. Good Luck!

jeffa


In reply to (jeffa) Re: Interpolating variables from a file by jeffa
in thread Interpolating variables from a file by Rich36

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.