Hi,
that's just a simple question, but I cannot find a way to operate with data in var, for example, what I can do using opened FILE Descriptor:
open(query, "netstat -na | awk '{print \$4}' | sort -nr |") || die "fi
+le not found!";
while(<query>)
{
($num, $ip) = split(' ');
print "output: $num $ip\n";
}
close(query);
How can I do the same with using VAR instead of FILE descriptor? with some thing like this:
$query = `netstat -ntu | awk '{print \$4}' | sort -nr`;
while(<$query>)
{
($num, $ip) = split(' ');
print "output: $num $ip\n";
}
However this "while" construction does not work, can you please help me? may be I should use "foreach" or something else?