use strict; use IO::File; my @groups = qx/net localgroup/; my $fhout = IO::File->new("g:\\iw-home\\scripts\\Test.txt", 'w'); foreach my $grp (@groups) { print $fhout $grp , "\n"; }