On Tue, Dec 03, 2002 at 11:51:22AM -0500, David Nolan wrote: > > > --On Monday, December 02, 2002 12:10 PM -0800 Jim Trocki > <[EMAIL PROTECTED]> wrote: > > >On Mon, 2 Dec 2002, David Nolan wrote: > > > > >>Unfortunately, since my current copy of Mon is HEAVILY patched, vs > >>0.99.2, just handing out a copy is probably not a good idea. > > > >have you done more than replace the calls to parse_line with calls to > >your own routine? if so, just send me a snippet of your routine and an > >example of how it's called. > > > > Actually, I took the approach of changing the protocol *slightly* in order > to make using split or a simple regexp possible. Basically in both mon and > Mon::Client change esc_str to escape spaces in addition to everything it > currently escapes. ('<= 32' instead of '< 32'). >
I decided to make no changes to mon protocol and just replace Text::ParseWords usage in Mon::Client with my own quotewords. Here is the patch: --- mon/Mon-0.11/Mon/Client.pm Thu Jan 11 08:42:17 2001 +++ mon/Client.pm Fri Dec 6 17:43:46 2002 @@ -447,7 +447,7 @@ require 5.004; use IO::File; use Socket; -use Text::ParseWords; +#use Text::ParseWords; @ISA = qw(Exporter); @EXPORT_OK = qw(%OPSTAT $VERSION); @@ -1006,7 +1006,7 @@ foreach $d (@d) { ($group, $service, $desc) = split (/\s+/, $d, 3); $desc{$group}{$service} = - _un_esc_str ((parse_line ('\s+', 0, $desc))[0]); + _un_esc_str ((quotewords ('\s+', 0, $desc))[0]); } return %desc; @@ -2099,3 +2099,13 @@ } return %alias; } + +sub quotewords { + my ($delim, $flag, $text) = @_; + @fields = (); + while ($text =~ m/([^\s']*'[^']*')\s?|([^\s]+)\s?|\s/g) { + push (@fields, defined($1) ? $1 : $2); + } + return @fields; +} Now monshow works for me under perl 5.8.0 (that's on SuSE Linux 8.1) with extra-long last_detail strings. -- Konstantin 'Kastus' Shchuka Unix System Administrator ePocrates Inc. tel 650.227.1786 fax 650.592.6995 _______________________________________________ mon mailing list [EMAIL PROTECTED] http://linux.kernel.org/mailman/listinfo/mon