Hi!
Would appreciate some help on the following simple issue:
I have 2 text files, names.txt and numbers.txt. Names contains a list of names and numbers contains a list of numbers. I have successfully managed to open both in my Perl program and output their content to arrays (named names and numbers). I need to create a new file called suppliers.txt containing the names and numbers together on one line in the following format name:number
To clarify, names.txt might have
mark
dave
mike
numbers.txt might have
5465
5345
8456
suppliers needs to have
mark:5465
dave:5345
mike:8456
Any help would be greatly appreciated
|
Newbie Member
|
|
| 25Jun2010,19:25 | #2 |
|
hi friend,
Sorry for my late reply to you. Just before i see your task so i now send my response to you.i dont know that it will be helped you or not. Anyway i just share my idea open (NAME, "c:/name.txt"); while ($line = <NAME>) { $line =~ s/\n//gs; push (@name, $line); } close NAME; open (NUM, "c:/num.txt"); while ($line = <NUM>) { $line =~ s/\n//gs; push (@num, $line); } close NUM; open (SUP, ">c:/sup.txt"); for ($i=0; $i<=$#name; $i++) { print SUP $name[$i] . ":" . $num[$i] . "\n"; } close SUP; |
