Greetings, I'm trying to parse out the following statement and convert it to an html table
Disk quotas for testuser (uid 65530): Filesystem usage quota limit timeleft files quota limit + timeleft /var/mail 1394 15360 16384 0 0 0 + /home 255999 307200 308224 34 0 0
My first thought was $quota_string =~ s/\s+/ /g; $quota_string =~ s/:/:\n/; and then try to match the whitespace /words and put a new line in front of it $quota_string =~ s/\s{1}\/$1\n/g; and then convert all the \n to <tr> and all the spaces to <td> I haven't entirely worked all the bugs out of this idea yet, because the mildly complicated regex doesn't work....

And then there is also the problem of, when converting all the whitespaces to one space the files field shifts over to the timeleft field... anyone have any thoughts on how to insert perhaps a "-" if there is nothing there?

I was considering something as hidous as this to help but....

my $ugly_regex = '! / # match / \w*? # match optional minimum word characters (/dir +) /? # match single optional / \w*? # match optional minimum word characters (/dir +/dir) /? # match single optional / \w*? # match optional minimum word characters (/dir +/dir/dir) /? # match single optional / \w*? # match optional minimum word characters (/dir +/dir/dir/dir) \s? # match a single optional whitespace \d+? # match 1 or more numbers \s? # match a single optional whitespace \d+? # match 1 or more numbers \s? # match a single optional whitespace \d+? # match 1 or more numbers \s? # match a single optional whitespace \d+? # match 1 or more numbers \s? # match a single optional whitespace \d+? # match 1 or more numbers \s? # match a single optional whitespace \d+? # match 1 or more numbers \s? # match a single optional whitespace \d*? # match 0 or more numbers \s? # match a single optional whitespace \d*? # match 0 or more numbers !x';
that is ugly as sin and........ yeah....doesn't work...
Anyone got any thoughts in that direction? I would use Quota, except this is over a remote connection and I cannot always be sure that module has been installed.

Update: By remote I mean through an telnet/ssh session emulated by either Net::Telnet or Net::SSH::Perl


jcpunk
all code is tested, and doesn't work so there :p (varient on common PM sig for my own ammusment)

In reply to patern matching whitespace, / and others by jcpunk

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.