<分区>
与 perlform ,我能够像这样格式化控制台输出:
#Print report
$~ = 'REPORT';
$^ = 'REPORT_TOP';
write ;
# Specify format
format REPORT_TOP =
Charge Code Hours Description
============= ======== ===============================================
.
format REPORT =
@<<<<<<<<<<<< @<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$reportChargeCode, $reportHours, $reportDescription
.
在 ruby 中有没有办法做同样的事情?
编辑:
我有一个循环,用于对存储在散列中的每个 reportChargeCode 的 reportHours 求和。所需的输出类似于:
Charge Code Hours Description
============= ======== ===============================================
CS5510 2.2575 hw13
ECE3710 5.678333 duck hunt game