Hi,

I am not sure if this can be done. But just asking it out of curiosity. I
have written this snippet.

use strict;
use warnings;

my $var = '$str abc_xyz';
my $str;

for(my $i=1;$i <= 5; $i++){
    $str = $i;
    my $line = 'Line: '.$var;
    print "$line\n";
}

Currently it displays:

Line: $str abc_xyz
Line: $str abc_xyz
Line: $str abc_xyz
Line: $str abc_xyz
Line: $str abc_xyz

But can I make it output following:

Line: 1 abc_xyz
Line: 2 abc_xyz
Line: 3 abc_xyz
Line: 4 abc_xyz
Line: 5 abc_xyz

i.e. I want $str to be dynamically replaced with the value of number.

~Parag

Reply via email to