>>>>> "RD" == Rob Dixon <rob.di...@gmx.com> writes:

  RD> use strict;
  RD> use warnings;

  RD> my $str;

  RD> sub var { "$str abc_xyz" }

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

using a global to get around symrefs is not a win. a template or sprintf
are much better solutions. even a one liner with a hash and s/// is
simple and effective for this (it is the simplest templater around).

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to