Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Uer Perl Variable in file

by Anonymous Monk
on Aug 06, 2012 at 14:24 UTC ( [id://985736]=note: print w/replies, xml ) Need Help??


in reply to Uer Perl Variable in txt file

I don't feel that I understand what you are getting, based on the snippet of source code that I see ... but here is one important thing to keep in mind: the difference between single and double quotes.

A string such as 'This is $name' will be output literally as it appears, whereas a string in double quotes such as "This is $name" will have the variable-name interpolated.   That is, if $name is Fred, you get:   This is Fred in the second case but not the first.

Replies are listed 'Best First'.
Re^2: Uer Perl Variable in file
by vinaybond (Novice) on Aug 06, 2012 at 14:40 UTC
    I have a file which has contents like this

    ______file.txt_______
    I am $name
    I am from $city
    I live $food
    I got $car


    Using perl code I am reading line one by one from file.txt. When I print line using $_ it does not replace variable in text file with variable values in .pl file but it prints the line as it is.
    -Vinay
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://985736]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-23 07:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found