Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Change C style Code into Perl on Windows

by mifflin (Curate)
on Jun 09, 2005 at 22:15 UTC ( [id://465343]=note: print w/replies, xml ) Need Help??


in reply to Change C style Code into Perl on Windows

It looks like you want to continually do a netstat and grep out only the lines that have the string '6000' in them.
I tried the following on my PC and on my unix box and it works on both (although I had to search for another number).
while (1) { print for (grep {/6000/} `netstat -n`); sleep 5; }

Replies are listed 'Best First'.
Re^2: Change C style Code into Perl on Windows
by Fletch (Bishop) on Jun 09, 2005 at 23:48 UTC

    Minor efficiency nit, but grep /6000/, `netstat -n` would be better as it avoids a BLOCK enter/leave for each line. If your grep test is a single EXPR rather than multiple statements it can shave a little time off. (And of course Benchmark to verify for your particular case if you're in doubt).

    --
    We're looking for people in ATL

      yep!
      erickn@cosmora01d:/home/erickn> cat xx use Benchmark qw(:all); cmpthese ( 10000000, {mifflin => &mifflin, fletch => &fletch } ); sub mifflin { grep {/6000/} qw(1 2 3 4 5 6000 7 8 9 10); } sub fletch { grep /6000/, qw(1 2 3 4 5 6000 7 8 9 10); } erickn@cosmora01d:/home/erickn> perl xx Rate mifflin fletch mifflin 5128205/s -- -19% fletch 6329114/s 23% --

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465343]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-24 15:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found