tags:

views:

46

answers:

3

With the following example script I try to print the parameter[1] content. My question is how to print also FLORIDA word (in place $VAL) so I will get FLORIDA on print output

#!/usr/bin/perl

my @parameter = ();
my $VAL=FLORIDA;

$parameter[1]='45487539
               $VAL
               5847366
               83564566';

print $parameter[1];

Output:

45487539
               $VAL
               5847366
               83564566
+1  A: 

The answer is to replace the single quotes "'" with double quotes """. Now it will work.

lidia
+2  A: 
$parameter[1]="45487539
               $VAL
               5847366
               83564566";

Try that.

adamse
A: 

If you need to dynamically replace variables from user supplied data, use the following syntax:

$parameters[1] =~ s/\$(\w+)\b/eval "return \$$1;"/ge;
print $parameters[1];
jmz
Using eval on user-supplied data is a a horrendous security risk.
Ether