Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I added a blank line to your data, and removed some data lines for simplicity. I know you said you wanted to use regex instead of split, but I do not understand why. Is this what you are trying to achieve?
#!/usr/bin/env perl use strict; use warnings; while ( <DATA> ) { next if /^HOSTNAME/; # skip title line next if /^\-/; # skip lines which start with "-" s/^\s+//; # remove whitespace at start of line s/\s+$//; # remove whitespace at end of line next if /^$/; # skip blank lines my ($host, $arch, $proc, $load, $memtot, $memuse, $swap, $swapuse +) = split; print "Using split function Host is $host\n"; } __DATA__ HOSTNAME ARCH NPROC LOAD MEMTOT MEMUSE SWAPTO + SWAPUS ---------------------------------------------------------------------- +--------- global - - - - - - + - Luke glinux 2 0.70 3.4G 919.5M 1.9G + 681.6M bobafett glinux 2 0.00 3.4G 205.8M 1.9G + 0.0 bones glinux 2 0.01 2.0G 150.9M 1.9G + 0.0 c3p0 glinux 2 0.37 3.4G 101.6M 1.9G + 7.2M dax glinux 4 0.81 2.0G 438.0M 1.9G + 272.1M geordi glinux 4 - 2.0G - 1.9G + - han glinux 2 0.53 3.4G 373.6M 1.9G + 243.3M janeway glinux 2 0.00 7.3G 351.9M 16.0G + 0.0 lando glinux 4 1.27 7.3G 445.8M 1.9G + 6.9M sisko glinux 2 - 2.0G - 1.9G + - sulu glinux 2 - 493.7M - 1019.7M + -
gives me this output:
Using split function Host is global Using split function Host is Luke Using split function Host is bobafett Using split function Host is bones Using split function Host is c3p0 Using split function Host is dax Using split function Host is geordi Using split function Host is han Using split function Host is janeway Using split function Host is lando Using split function Host is sisko Using split function Host is sulu

In reply to Re: I have done this before by toolic
in thread I have done this before by monk2b

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-03-28 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found