perl formats
Stephane Rondal
rondal at usa.net
Tue Jan 9 15:51:51 CST 2001
Using perl formats, I'm simply trying to print:
|x|, that is x, a meanlingless value, ***enclosed between
two 'or' bars, without additional spaces***
So, here goes:
format STDOUT =
|@|
$x
The problem with this is that it will print (for $x = 1):
|1
The second 'or' bar is missing because it has been interpreted
by perl as the center aligned format directive.
I've also tried |@<| and other variants, as well as escaping the
'or' bar, but I always end up with an unwanted space between 1
and the closing 'or' bar, or even the escape character '\' itself.
Finally I came up with:
format STDOUT =
|@<
$x.'|'
which means: left aligned on 2 characters (@<) and use the concatenation
operator to manually add the closing 'or' bar.
THERE'S GOT TO BE A BETTER WAY!
Any ideas?
Stephane
PS. I know this may seem an overkill use of perl formats,
but this is just part of a bigger format
More information about the Liege-pm
mailing list