develooper Front page | perl.beginners | Postings from January 2002

Variable interpolation?

Thread Next
From:
Mad B . Jones
Date:
January 6, 2002 05:03
Subject:
Variable interpolation?
Message ID:
1103_1010322062@cat
Hi everyone. A little thing I fail to understand...

This of course works:
    $name="Dave";
    $string="Hello $name";
    print $string;
outputting:
    Hello Dave

Why, then, does it not work when I get the string "Hello $name" out of a file?
    $name="Dave";
    $in="textfile.txt";
    open(INFILE, "<$in");
    @string=<INFILE>;
    $string="$string[0]";
    print $string;
The output is:
    Hello $name

Thanks a million if anyone has the answer

Dave Jones


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About