in reply to Re: Accumulating Column Total for a Particular Key
in thread Accumulating Column Total for a Particular Key


Thanks for the help, but unfortunately for some reason
most of the CPAN modules are not installed on this
server.
  • Comment on Re^2: Accumulating Column Total for a Particular Key

Replies are listed 'Best First'.
Re^3: Accumulating Column Total for a Particular Key
by jZed (Prior) on Aug 27, 2007 at 16:54 UTC
Re^3: Accumulating Column Total for a Particular Key
by GertMT (Hermit) on Aug 28, 2007 at 06:54 UTC
    withouth using modules something like this?
    Gert
    #!/usr/bin/perl -w use diagnostics; use strict; my $sum0 = 0; my $sum1 = 0; printf "%-9s\t%-35s\t%8s\t%14s\n", "Login ID", "Application", "CPU Min +utes", "Percent of Total"; print "-" x 88 . "\n"; while (<DATA>) { tr/%//d; chomp; next if /^Login/; my @F = split /,/, $_; $sum0 += $F[2]; $sum1 += $F[3]; printf "%-9s\t%-35s\t%5s\t\t%4.1f\n", "$F[0]", "$F[1]", "$sum0", " +$sum1"; } __DATA__ Login ID,Application,CPU Minutes,Percent of Total s2pe,CTI Production ,8455,21.7% sybprd01,OMS,5326,13.7% pctip01,CTI,5098,13.1% lxsadr54,CTI,1742,4.5% pipmp01,SSG-IPM,1742,4.5% maestro,SSG-RAC-Maestro ,1020,2.6% f2pa,"DB2DARI ""stored procedures"" prod",836,2.1% pomgp01,SSG-PMD-Omegamon,56,0.1% pptip01,PTI - Private Client Services,16,0.0% pbmwp01,BMW,3,0.0% s2pv,Merva,1,0.0%