I am sure there are better ways as I am learning as well, but how
about doing something like this. This is assuming both arrays have the
same number of elements.

open MYFILE, ">>f1.txt";
for (0..$#alpha) {
    print MYFILE "$alphaid[$_]\t";
    print MYFILE "$betaid[$_]\n";
}

On Feb 11, 2008 12:11 PM,  <[EMAIL PROTECTED]> wrote:
> Hi,
>     I am learning to print two arrays in a single file but unable to
> do. So, I am printing it in two files. Any ideas
>
> # Populating the arrays @alphaid and @betaid
> foreach my $line (@File1)
>      {
>         if ($line =~ /^AC/)
>           {
>             $line =~ s/^AC\s*//;
>               @alphaid = $line;
>               push(@alphaid,$_);
>           }
>
>         if ($line =~ /^DR/)
>            {
>             $line =~ s/^DR\s*//;
>               @betaid = $line;
>               push(@betaid,$_);
>            }
>      }
>
> #Printing the arrays in two files. Here I would like to have them in a
> single with tab character separating the #arrays such as
> # alphaid[1] \t  betaid[1]
> # alphaid[1] \t  betaid[2]
> # and so on
>
>          foreach $alphaid (@alphaid)
>               {
>               open (MYFILEG, '>>f1.txt');
>               print MYFILEG @alpha;
>               close (MYFILEG);
>                }
>
>         foreach $betaid (@betaid)
>              {
>               open (MYFILEE, '>>f2.txt');
>               print MYFILEE @betaid;
>               close (MYFILEE);
>            }
>
> any help will be appreciated.
> -K
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to