in reply to variable interpolation

Why? You have already asked at least twice about symbolic reference related issues. I suspect you have settled on what is probably a fundamentally wrong approach to solving a problem and as a result are asking a slew of XY questions.

Please tell us what your bigger problem is so that we can stop giving you bad and/or contradictory advice. Generally any solution requiring symbolic references or string eval are bad (not all, but most) and there are better ways of solving the problem.


True laziness is hard work

Replies are listed 'Best First'.
Re^2: variable interpolation
by Anonymous Monk on Feb 27, 2009 at 12:42 UTC
    Hi, I have a line read in perl from a file that itself is a source code for languages like c/sv etc. The variable containing this line contains special characters like %d. When i print this line to another file, the %d is evaluated and a 0 is getting printed. How do i overcome this and tell perl to strictly not interpolate/evaluate any contents of this variable and simply print it as is ! ~Pushkar

      Show us some sample code! I can think of a number of ways you might get that result, and none of them are good technique.

      Oh, and always use strictures (use strict; use warnings;). You are probably doing something silly that strict would tell you about.


      True laziness is hard work
        Herez the sample code requested :
        open FRH "<File1.txt"; open FWH ">File2.txt"; while($line = <FRH>) { chop($line); printf FWH "$line\n"; } close FRH; close FWH; --------------------------------------------- File1.txt ********* ovm_report_info("DBG_INFO", $psprintf("Num of Register Fields to Progr +am is : %d", m_uint_num_of_reg_fields_to_program), OVM_HIGH); ovm_report_info("DBG_INFO", $psprintf("Programming Bank %d Reg %d", (i +/32), l_uint_reg_num), OVM_HIGH); File2.txt ********* ovm_report_info("DBG_INFO", $psprintf("Num of Register Fields to Progr +am is : 0", m_uint_num_of_reg_fields_to_program), OVM_HIGH); ovm_report_info("DBG_INFO", $psprintf("Programming Bank 0 Reg 0", (i/3 +2), l_uint_reg_num), OVM_HIGH);

        Code tags added by GrandFather