drieux wrote: > On Friday, May 31, 2002, at 02:13 , Sudarsan Raghavan wrote: > > > while (<INPUTDATA>) { > > chomp; > > s/^\s+//; > > next if ((1 .. /^NPROC/) || m/^$/); > > # The conditions have been swapped here > > # Explanation for this is one of my earlier mails > > unless (/^Total/) { > > # Assumes the line to stop searching for input starts > > with Total > > my ($user, $mem, $cpu) = (split (/\s+/))[1, 4, 6]; > > print "user = $user, mem = $mem, cpu = $cpu\n"; > > } > > } > > this is still generating: > > user = USERNAME, mem = STATE, cpu = NICE > user = prago, mem = cpu49, cpu = 0 > user = oracle, mem = cpu46, cpu = 0 > user = prago, mem = sleep, cpu = 0 > user = oracle, mem = sleep, cpu = 0 > user = oracle, mem = sleep, cpu = 0 > user = prago, mem = sleep, cpu = 0 > user = USERNAME, mem = MEMORY, cpu = CPU > user = prago, mem = 2.9%, cpu = 11% > user = oracle, mem = 91%, cpu = 4.1% > user = patrol, mem = 0.2%, cpu = 0.2% > user = dbmsys, mem = 0.1%, cpu = 0.1% > user = root, mem = 0.8%, cpu = 0.1%
This means the range condition check is always returning false. Works for me though, with the same input it outputs user = prago, mem = 2.9%, cpu = 11% user = oracle, mem = 91%, cpu = 4.1% user = patrol, mem = 0.2%, cpu = 0.2% user = dbmsys, mem = 0.1%, cpu = 0.1% user = root, mem = 0.8%, cpu = 0.1% Can the OP confirm if it works fine I cut-pasted the input from original mail. Can you attach the file that you are using as input so that I can test it here. You can also change the if to next if (1 .. /^NPROC/ or m/^$/); This really is not a fix just playing around with precedence > > > given the input data set of: > > PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP > > 13261 prago 5728K 5240K cpu49 0 0 0:40.04 9.4% cfprsdrv/1 > 20318 oracle 519M 496M cpu46 0 0 35:47.20 3.2% oracle/1 > 12924 prago 1720K 1056K sleep 1 0 0:06.55 1.6% zcat/1 > 21244 oracle 514M 494M sleep 0 0 0:00.01 0.3% oracle/1 > 21107 oracle 526M 507M sleep 0 0 0:00.13 0.3% oracle/1 > 13310 prago 392M 101M sleep 59 0 0:01.07 0.2% syncsort/1 > NPROC USERNAME SIZE RSS MEMORY TIME CPU > > 17 prago 1596M 394M 2.9% 0:48.54 11% > 47 oracle 13G 12G 91% 38:17.25 4.1% > 5 patrol 36M 23M 0.2% 10:53.17 0.2% > 11 dbmsys 52M 20M 0.1% 0:00.53 0.1% > 53 root 173M 113M 0.8% 5:32.40 0.1% > Total: 208 processes, 875 lwps, load averages: 2.03, 2.04, 2.12 > > cf: > http://www.wetware.com/drieux/pbl/Sys/Admin/ciscoParse2.txt > which given the same input file generates: > > user prago hogs 2.9% memory and 11% cpu > user oracle hogs 91% memory and 4.1% cpu > user patrol hogs 0.2% memory and 0.2% cpu > user dbmsys hogs 0.1% memory and 0.1% cpu > user root hogs 0.8% memory and 0.1% cpu > we do not like:Total: 208 processes, 875 lwps, load averages: 2.03, 2.04, > 2.12 > > which I think is closer to the OP's preferred choice. > > and may I put a plug in for the > > use Inline::Files; > > WAY too wicked slick a solution for skanking test cases like this. > > ciao > drieux > > --- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]