in reply to Get an input file and print multiple output files after performing operations on array.

#! perl -slw use strict; my @city = split ' ', <DATA>; my @temp = split ' ', <DATA>; my @note = split ' ', <DATA>; my $i = '01'; for my $city ( @city ) { for my $temp ( @temp ) { for my $note ( @note ) { open O, '>', 'out' . $i++ or die $!; print O 'city: ', $city; print O 'weather: ', $temp; print O 'recommended: ', $note; close O; } } } __DATA__ Jakarta paris delhi singapore hot cold wet yes no cannotcomment

Output:


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Get an input file and print multiple output files after performing operations on array.
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Get an input file and print multiple output files after performing operations on array.
by Ganesh Bharadwaj1 (Sexton) on Dec 29, 2015 at 06:36 UTC
    thank you soo much. That works like a charm :)