•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 375,274 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,218 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser:
I've seen this question (or similar) asked many times on forums:
I have a variable in a file (text) and want to expand it. For example, I have this line in a text file:
Mary had a little $lamb
and I want to be able to expand $lamb but text files are treated as single-quoted strings and perl does not interpolate variables in single-quoted strings.
I have a variable in a file (text) and want to expand it. For example, I have this line in a text file:
Mary had a little $lamb
and I want to be able to expand $lamb but text files are treated as single-quoted strings and perl does not interpolate variables in single-quoted strings.
Last edited : May 16th, 2007.
my $lamb = 'wolf'; my $text = 'Mary had a little $lamb.'; $text =~ s/(\$\w+)/$1/eeg; print $text;
Post Comment
•
•
•
•
DaniWeb Marketplace (Sponsored Links)