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.
I seem to recall something similar in Fortran when I used it many years ago (however, it may well have have been a third-party library).
As for other options in Perl, have a look at Perl6::Form
.
The form
function replaces format
in Perl6. Damian Conway in "Perl Best Practices" recommends using Perl6::Form
with Perl5 citing the following issues with format
....
Here is a Perl6::Form
variation on the Ruby example by Robert Gamble....
use Perl6::Form;
my ( $month, $day, $year ) = qw'Sep 18 2001';
my ( $num, $numb, $location, $toe_size );
for ( "Market", "Home", "Eating Roast Beef", "Having None", "On the way home" ) {
push @$numb, ++$num;
push @$location, $_;
push @$toe_size, $num * 3.5;
}
print form
' Piggy Locations for {>>>}{>>}, {<<<<}',
$month, $day, $year ,
"",
' Number: location toe size',
' --------------------------------------',
'{]}) {[[[[[[[[[[[[[[[} {].0} ',
$numb, $location, $toe_size;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With