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.
In reply to Re: Need to replace string from external file
by hippo
in thread Need to replace string from external file
by bhupi70007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |