使用Perl进行格式化输出的最佳方式 [英] Best way to have a formatted output with Perl

查看:152
本文介绍了使用Perl进行格式化输出的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想输出字符串到八列,但我想保持相同的间距。我不想用HTML来做,但我不确定如何正常使用。例如:

pre $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $



$ b $另外一个另外的另一个

行数将每天更改,但列号始终保持不变。什么是最好的办法呢?

/ perlfunc#printfrel =noreferrer> printf

  printf%-11s%-11s%-11s%-11s%-11s%-11s%-11s%-11s\\\

$ column1,$ column2,...,$ column8 ;

将模板中的11更改为您需要的任何值。

I want to output strings into eight columns, but I want to keep the spacing the same. I don't want to do it in HTML, but I am not sure how to do it normally. Example:

Something    Something     Something     Something     Something
Else         Else          Else          Else          Else
Another      Another       Another       Another       Another

The amount of rows will change daily, but the column number will always stay the same. What is the best way to do this?

解决方案

printf

    printf "%-11s %-11s %-11s %-11s %-11s %-11s %-11s %-11s\n",
            $column1, $column2, ..., $column8;

Change "11" in the template to whatever value you need.

这篇关于使用Perl进行格式化输出的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆