azaria has asked for the wisdom of the Perl Monks concerning the following question:
I initialized a variable and then I parse a text file which includes this variable, while I print this line it is not substitute, means:
for example: 1. Input file: My name is $str1 I live in $str2 I like to eat $str1 2. Perl script #! /usr/local/bin/perl $str1 = "MIKE"; open(DB,"list.txt") || die "ERR: failed to open DB\n"; @all_lines = <DB>; close(DB); @found = grep(/^My/,@all_lines); print @found,"\n"; #######################
Here I see the the line is printed but not substituted with my initialzed $str1 val. Any idea I it can smoothly resolved ?
Thanks
azaria
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: substitue variables from file
by bart (Canon) on Oct 29, 2005 at 21:32 UTC | |
by azaria (Beadle) on Oct 29, 2005 at 21:44 UTC | |
by dragonchild (Archbishop) on Oct 30, 2005 at 02:15 UTC |