Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

perltidy breaking before '=' ?

by Anonymous Monk
on Sep 16, 2006 at 11:44 UTC ( [id://573325]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I trying to get perltidy to break before an assignment. having
my $bla = 'a string' . 'another string' . 'yet another' . 'too much fo +r one line';
perltidy -pbp -l=72 -vt=0 produces
my $bla = 'a string' . 'another string' . 'yet another' . 'too much for one line';
I would like to get
my $bla = 'a string' . 'another string' . 'yet another' . 'too much for one line';
TIA Thomas

Replies are listed 'Best First'.
Re: perltidy breaking before '=' ?
by hgolden (Pilgrim) on Sep 16, 2006 at 13:52 UTC
    I'm having a lot of trouble installing Perltidy on my home machine, so I haven't been able to test this. However, looking at the docs, it's seems like you want to add -wbb="=", since wbb is "want break before" (there's also wba, "want break after"). Depending on how Perltidy works, this might cause unexpected behavior around tokens like =~, but as I've said, I can't test this. Best of luck.

    Hays

Re: perltidy breaking before '=' ?
by graff (Chancellor) on Sep 16, 2006 at 16:23 UTC
    This strikes me as a rather nit-picky detail, but I can understand why you would want this behavior. The question is: is it only this sort of statement that is making trouble for you? If so, how bad is it just to edit perltidy's output yourself to fix these cases? Or, if there are a lot of these, and they all end up following the same basic pattern, why not try an ad-hoc filter on the perltidy output -- something like:
    s/^(\s*)(my\s+[^\s=]+)\s*(=[^;]+)$/$1$2\n$1 $3/;
    For lines that look like  my $var = ... and lack a semi-colon on the rhs, this substitution will put any indentation that precedes "my", plus another four spaces of indentation, at the beginning of a new line that holds just the "= ..." portion.
      If so, how bad is it just to edit perltidy's output yourself to fix these cases?

      As I understand it, the ideal is to use Perltidy quite often, as one part of the edit cycle, cleaning up any unintentional goofs and restoring to the 'standard' formatting. Perltidy is not a one-time or once-a-month thing, rather it is supposed to be done at least before each time you check your changes back into the repository.

      So you shouldn't have to clean up after the cleaner-upper. Indeed, it is this problem that has so far kept me from using Perltidy as intended.

Re: perltidy breaking before '=' ?
by leriksen (Curate) on Sep 17, 2006 at 12:17 UTC
    I dont know how to do exactly what you want, but you may find it easier to use a new tool I've posted to sourceforge - [TidyView] I plan to post a more general announcement to Perl Monks this week.

    ...reality must take precedence over public relations, for nature cannot be fooled. - R P Feynmann

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://573325]
Approved by hsinclai
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2025-06-17 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.