Anish Kumar K. wrote:
Hi I need help regarding substituion of varaibles with values

That is a Frequently Asked Question.

perldoc -q "How can I expand variables in text strings"


Say I have a txt file (a.txt)

which has only one line:
Hi $name

The PL file
========
open INPUT, "a.txt";

You should *ALWAYS* verify that the file opened correctly.

open INPUT, '<', 'a.txt' or die "Cannot open 'a.txt' $!";


my $name="Anish";
my $temp="";
while (<INPUT>)
{
  $temp=$temp.$_;
}

The usual way to slurp the entire contents of a file is:

my $temp = do { local $/; <INPUT> };


Or you could use the File::Slurp module.


close(INPUT);
print "Content is: $temp";

In the output I want the $name to get as Anish..O/P like Hi Anish



John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to