Convert perl qw list to text file list?

Does anyone have a good example? I am having trouble looping..

Thanks

Something like this?

#!/usr/bin/perl

my $outfile = 'fruits.txt';
my @fruits = qw(apple banana orange);

open(OUT,">$outfile") or die $!;

foreach my $fruit (@fruits) {
        printf OUT "$fruit\n";
    }

close(OUT);