Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: Perl solution

by shmem (Chancellor)
on Jan 27, 2008 at 19:54 UTC ( #664555=note: print w/replies, xml ) Need Help??

in reply to Perl solution

The CoC* service responds: insert coin here.

Seriously, what problems do you have, what did you try, did you read the PerlMonks FAQ and not stumble over How do I post a question effectively? Hard to believe.

For a starter,

netstat -e | perl -ple 's/\s\s+/\t/' > file.csv

writes the output of netstat -e into a tab delimited csv file. You have to tweak the regular expression used in that snippet according to the spec.

What spec? Ah, uhm, wait, er...

*) Crank out Code


_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: Perl solution
by pilcrow (Sexton) on Jan 28, 2008 at 06:15 UTC
    netstat -e | perl -ple 's/\s\s+/\t/' > file.csv

    Very likely an intended g modifier is missing from that s///. Of course, without a problem specification, who can say for sure that the g is needed? :)

Re^2: Perl solution
by apotheon (Deacon) on Jan 28, 2008 at 03:21 UTC
    a tab delimited csv file

    I think you mean "a tsv file". A csv file is, by definition, comma delimited. A better version would probably be something like this:

    netstat -e | perl -ple 's/\s\s+/,/' > file.csv

    . . . and, of course, neither of our versions are exactly perfect/complete.

    print substr("Just another Perl hacker", 0, -2);
    - apotheon
    CopyWrite Chad Perrin

      You are certainly not wrong, but it could be argued that csv became a 'backronym' of Character Separated Values.

      How can you feel when you're made of steel? I am made of steel. I am the Robot Tourist.
      Robot Tourist, by Ten Benson

Re^2: Perl solution
by Gavin (Bishop) on Jan 30, 2008 at 16:33 UTC
    ** or Cockup Operations Corrector

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2020-01-18 17:30 GMT
Find Nodes?
    Voting Booth?