in reply to Need to replace string from external file
i have a file1 which contain text "My name is %s" I have an second file which contain mutiple values for %s replacement i.e file2 have John, peter, jessus etc Hence i need a output file that conatins output like My name is John My name is Peter My name is jessus
Sounds like a job for printf to me:
#!/usr/bin/env perl use strict; use warnings; my $text = "My name is %s\n"; my @args = qw/John peter jessus/; printf $text, $_ for @args;
File input left as an exercise.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need to replace string from external file
by bhupi70007 (Novice) on Nov 06, 2017 at 11:57 UTC | |
by hippo (Archbishop) on Nov 06, 2017 at 12:17 UTC | |
by bhupi70007 (Novice) on Nov 06, 2017 at 11:58 UTC | |
by karlgoethebier (Abbot) on Nov 06, 2017 at 14:24 UTC |