I got your problem.

Pass the parameters like below,
&replace_txt('\$a', '$b');

It will work fine.

In this line, $line =~ s/$old/$new/g;
$old should have \$a, in order to match a variable name.
If u pass '$a' alone - &replace_txt('$a', '$b');
$old will have $a and it will search for the value of $a and not actual $a.

Hope u will get this.

Thanks,
Suresh


On Wed, Dec 30, 2009 at 2:25 PM, Masato Sogame <poketo7...@yahoo.co.jp>wrote:

> Sorry, Suresh my English was bad.
> I want to replace string '$a' to '$b' in $ARGV[0]
> For example if I write text file like this:
>
> my $a = "Hello,World";
> print $a;
>
> And I pass this text file to my script then I want to output like this:
>
> my $b = "Hello,World";
> print $b;
>
> So I want to pass old text and new text as argument of my subroutine.
> (More simple just "I want to replace variable name in my text file.")
>
>  HI
>>
>> Pass the parameters in double quotes or simply $a, $b. Like below
>> &replace_txt("$a", "$b");
>> &replace_txt($a, $b);
>>
>> Single quotes doesn't interpolate the variables.
>>
>> Thanks,
>> Suresh
>>
>
> --------------------------------------
> Get Disney character's mail address on Yahoo! Mail
> http://pr.mail.yahoo.co.jp/disney/
>



-- 
Thanks,
Suresh

Reply via email to