Ugly but may work, with a simple eval use strict; use warnings;
my $var = '$str. q( abc_xyz)'; my $str; for(my $i=1;$i <= 5; $i++){ $str = $i; my $line = 'Line: '.eval $var; print "$line\n"; } Best Regards Marcos On Sun, Apr 17, 2011 at 20:23, Shlomi Fish <shlo...@iglu.org.il> wrote: > Hi Parag, > > On Sunday 17 Apr 2011 21:07:27 Parag Kalra wrote: >> 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"; >> } >> > > The proper way to do it is to use a templating engine. See: > > http://perl-begin.org/uses/text-generation/ > > http://perldoc.perl.org/functions/sprintf.html should be enough here. > > Regards, > > Shlomi Fish > > -- > ----------------------------------------------------------------- > Shlomi Fish http://www.shlomifish.org/ > "The Human Hacking Field Guide" - http://shlom.in/hhfg > > Judaism: God is all the shit, all the non-shit and all the intermediate > demi-shits in between. > > Please reply to list if it's a mailing list post - http://shlom.in/reply . > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > > -- Marcos Rebelo http://www.oleber.com/ Milan Perl Mongers leader https://sites.google.com/site/milanperlmongers/ Webmaster of http://perl5notebook.oleber.com -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/