Dear Perl beginners and mentors thereto,

I would like to use perltidy to left-align side comments
in a Perl script to a specific column, if possible.
That is, I want an option like: --left-align-side-comments=n
which would tell perltidy to left-align each side comment
in a file at column n if text to the left of the side
comment ends before column n (that is, if there is room).

For example, I want to change code like this:

$i = 1; # a side comment
$j = 1; # a side comment
$a_long_string = "Imagine this is quite long.";

to this:

$i = 1; # a side comment
$j = 1; # a side comment
$a_long_string = "Imagine this is quite long.";

where the # character appears in a column I specify, and
if the rest of the line allows it.

I read the perltidy manual and I tried a few combinations
of options, but can't find any way to align the side
comments file-wide. In particular, I seem to be running
into problems with Perl scripts that contain very long
strings. perltidy can line up the side comments to some
degree, but I get various results depending on other
options I specify, such as whether to outdent the long
strings or whether to break long lines. I would like to
nail down the starting column of the side comments so they
don't wander around depending on other formatting options.

I thought I would run this problem by perl.beginners
before I e-mail the author of perltidy, in case the
answer is boneheadedly obvious and I'm missing something.
I suspect there must be some way to do this because
aligning side comments file-wide seems like something
a person would obviously want. I might be projecting
what seems obvious to me.

If what I'm trying to do is not obvious from the above
description, I could present specific examples of
code with various formatting options to illustrate the
problems I am having. But if such examples are necessary,
that probably means perltidy has no option to left-align
side comments to a specific target column.

-- Daniel Mocsny