Help for this page

Select Code to Download


  1. or download this
    my $string = 'foo: $foo and bar: $bar\n';
    print $string, "\n";
    ...
    my $bar = "barzleberry foo";
    
    print eval 'qq(' . $string . ')';
    
  2. or download this
    my %vars = (
        foo => 'foozleberry pie',
    ...
    my $string = 'foo: $foo and bar: $bar'; 
    $string =~ s/\$(\w+)/$vars{$1}/g; 
    print $string, "\n";