in reply to How can one re-parse(?) a string to fill in variables
Which you want to print 'Hello Alex', but currently it's printing 'Hello $name!'.#!/usr/bin/perl -w use strict; my $name = 'Alex'; my $greeting = 'Hello $name!'; print $greeting;
#!/usr/bin/perl -w use strict; my $name = 'Alex'; my $greeting = 'Hello $name!'; $greeting =~ s|\$([\w_]+)|eval "\${$1}"|e; print $greeting;
|
|---|