RE: Need help with perl
Posted in 2001
Perl is so much nicer. try: while (<>) { ( $dbsnum , $name, $chksize, $nfree ) = split ; $chunk{$name}+= $chksize ; # here we create a hash array # where the index is the name $free{$name}+= $nfree; } foreach $name ( sort ( keys ( %chunk ))) { $free = 100 * $free{$name} / $chunk{$name} ; print "Chunk $name is $free percent full \\n"; } ## thats it !!! Isaac __________________________________ Isaac Loven. Melbourne _________________________________________________________ > Hi all, > > I need to write a simple "perl" script to calculate the free spaces in > (%). But I am facing a problem in adding up (chksize) for the dbsnum =11 > (there are 2 chunks over here). How should add up the 2 chunks ? > > > > > dbsnum name chksize nfree > > 1 jkta_root_dbs 512000 344953 > 2 jkta_log_dbs 1024000 4043 > 3 jkta_tmp_dbs1 1024000 1011167 > 4 jkta_tmp_dbs2 1024000 1001103 > 5 gop_dbs1 128000 45975 > 6 gop_dbs2 179200 126211 > 7 gop_dbs3 332800 140117 > 8 sam_dbs1 409600 29184 > 9 sam_dbs2 921600 175717 > 10 sam_dbs3 870400 127687 > 11 sam_dbs4 1024000 19650 > 11 sam_dbs4 665600 354779 > 12 sis_sd_dbs 256000 0 > 13 sis_sd_idx 102400 6959 > 14 sis_sas_dbs 51200 51147 > 15 sis_sas_idx 51200 19803 > 16 sis_gen_dbs 1024000 0 > 17 sis_gen_idx 512000 97133 > 18 sis_gas_dbs 153600 153547 > >