还有哪些其他语言具有类似于 Perl 格式的功能和/或库? [英] What other languages have features and/or libraries similar to Perl's format?

查看:17
本文介绍了还有哪些其他语言具有类似于 Perl 格式的功能和/或库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里可能是少数,但我非常喜欢 Perl 的格式.我特别喜欢能够在一列中包含一段长文本 ("~~ ^<<<<<<<<<<<<<<" 类型的东西).是否有任何其他具有类似功能的编程语言或实现类似功能的库?我对任何为 Ruby 实现类似功能的库特别感兴趣,但我也对任何其他选项感到好奇.

I may be in the minority here, but I very much enjoy Perl's formats. I especially like being able to wrap a long piece of text within a column ("~~ ^<<<<<<<<<<<<<<<<" type stuff). Are there any other programming languages that have similar features, or libraries that implement similar features? I am especially interested in any libraries that implement something similar for Ruby, but I'm also curious about any other options.

推荐答案

FormatR 为红宝石.

这是文档中的一个示例:

Here is an example from the documentation:

require "formatr"
include FormatR

top_ex = <<DOT
   Piggy Locations for @<< @#, @###
                     month, day, year

Number: location              toe size
-------------------------------------------
DOT

ex = <<TOD
@)      @<<<<<<<<<<<<<<<<       @#.##
num,    location,             toe_size
TOD

body_fmt = Format.new (top_ex, ex)

body_fmt.setPageLength(10)
num = 1

month = "Sep"
day = 18
year = 2001
["Market", "Home", "Eating Roast Beef", "Having None", "On the way home"].each {|location|
    toe_size = (num * 3.5)
    body_fmt.printFormat(binding)
    num += 1
}

产生:

   Piggy Locations for Sep 18, 2001

Number: location              toe size
-------------------------------------------
1)      Market                   3.50
2)      Home                     7.00
3)      Eating Roast Beef       10.50
4)      Having None             14.00
5)      On the way home         17.50

这篇关于还有哪些其他语言具有类似于 Perl 格式的功能和/或库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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