httpd has asked for the wisdom of the Perl Monks concerning the following question:
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:
However this "while" construction does not work, can you please help me? may be I should use "foreach" or something else?$query = `netstat -ntu | awk '{print \$4}' | sort -nr`; while(<$query>) { ($num, $ip) = split(' '); print "output: $num $ip\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: simple question about printing vars
by moritz (Cardinal) on Nov 03, 2011 at 12:45 UTC | |
by httpd (Novice) on Nov 03, 2011 at 13:11 UTC | |
|
Re: simple question about printing vars
by choroba (Cardinal) on Nov 03, 2011 at 12:43 UTC | |
by httpd (Novice) on Nov 03, 2011 at 13:07 UTC | |
by choroba (Cardinal) on Nov 03, 2011 at 13:40 UTC | |
by httpd (Novice) on Nov 03, 2011 at 13:49 UTC | |
by reisinge (Hermit) on Nov 03, 2011 at 14:48 UTC | |
by httpd (Novice) on Nov 03, 2011 at 16:02 UTC |