解决方法
my $output = qx(powercfg -l); ## You've got your output loaded into the $output variable. ## Still want to write it to a file? open my $OUTPUT,'>','output.txt' or die "Couldn't open output.txt: $!\n"; print $OUTPUT $output; close $OUTPUT ## Now you can loop through each line and ## parse the $line variable to extract the info you are looking for. foreach my $line (split /[\r\n]+/,$output) { ## Regular expression magic to grab what you want }