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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.