in reply to Execute a command line and save in memory its output

Using back ticks, something like this should work in most cases:
my $command = qq(ncks -v $variable -d station,$id,$id $file | grep \"s +tation\\[\"); my @output = `$command`;