in reply to Alignment of text using regex
While both, jettero & imp, have provided perfectly suitable solutions for aligning two or more values using a formatstring, you perhaps might be interested what format offers, especially if you become interested in having multiple values output in a formatted way, where, for example, the alignment differs from value to value.
Example code
#!/usr/bin/perl use strict; use warnings; my @elems = qw(left centered right); format = ------------------------------------------ @<<<<<<<<<<<<< @||||||||||| @>>>>>>>>>>>>> @elems ------------------------------------------ . write;
outputs
------------------------------------------ left centered right ------------------------------------------
Update: Added code.
|
|---|