Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I insert a variables name from a string in Perl?
    primarykey
    data
    text
    <p>I am trying to insert a variable <code>$font1</code> below. The variable <code>$font1</code> is the name of the font e.g. arial. I really want it to return <code>$arial</code> (or whatever <code>$font</code> is) as a variable.</p> <p>When <code>$arial</code> is called, it gets the arial.ttf from a folder on my server via get_fonts.pl.</p> <p>I have tried everything <code>\$$font</code> <code>'"$font"'</code> and every possible variation of that.</p> <p>I even tried <code>if ($font=="arial"){$font = a ton of different attempts;}</code></p> <pre><code>do "get_fonts.pl"; &amp;GetFonts($im); foreach $key (keys %ENV) { if($key !~ /[A-Z]/){ if ($key="sometext") { $text="$ENV{'typetext'}"; $color="$ENV{'typecolor'}"; $font="$ENV{'typefont'}"; $size="$ENV{'typesize'}"; $string = qq~ $text ~; $gd_text = GD::Text-&gt;new() or die GD::Text::error(); $gd_text-&gt;set_font($arialb, $size) or die $gd_text-&gt;error; $gd_text-&gt;set_text($string); my ($w, $h) = $gd_text-&gt;get('width', 'height'); $y1 = (300 / 6); if ($w &lt;= 380) { $x1 = ((400 / 2) - ($w / 2)); $im-&gt;stringFT("$blue", $font1, $size, 0, $x1, $y1, "$string"); } ... </code></pre> <p>Pay no attention to excluded ending brackets..</p> <p>Notice whare I called <code>$font1</code>.. If I call <code>$arialb</code> all is fine.</p> <p>Here is get fonts</p> <pre><code>sub GetFonts { my($im) = $_[0]; $arial = "fonts/arial.ttf"; # I tried Tons of things here to no avail if ($font=="arialb") { $font1 = '$arialb'; # and so many different other attempts } $arialb = "fonts/ariblk.ttf"; $ariali = "fonts/ariali.ttf"; $arialbi = "fonts/arialbi.ttf"; $comic = "fonts/comic.ttf"; $comicb = "fonts/comicbd.ttf"; $verdana = "fonts/verdana.ttf"; $verdanab = "fonts/verdanab.ttf"; $verdanai = "fonts/verdanai.ttf"; $verdanabi = "fonts/verdanaz.ttf"; } </code></pre> <p>I also desire to do the same with <code>$color</code> but, once <code>$font</code> is figured out, I should be able to fiqure that out.</p> <p>Thanks for any help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload