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 wil开发者_运维技巧l 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
$parameter[1]="45487539
$VAL
5847366
83564566";
Try that.
The answer is to replace the single quotes "'
" with double quotes ""
".
Now it will work.
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];
精彩评论