Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Best practices and any way to have Perl Tidy clean it up

by walkingthecow (Friar)
on Apr 14, 2013 at 15:22 UTC ( #1028631=note: print w/ replies, xml ) Need Help??


in reply to Re: Best practices and any way to have Perl Tidy clean it up
in thread Best practices and any way to have Perl Tidy clean it up

Thank you! That's pretty much exactly what I was looking for. I actually use the -pbp (perl best practices) flag with Perl Tidy, which sets 78-column lines for my scripts, but does not touch object params for some reason. So, 99% of my script is shortened down to 78-column lines, then I have these stragglers, these long lines that are object params. Guess I will have to do it manually (no big deal) to fit within the suggestions given above. The -pbp flag I believe sets all options to that which you find in the perltidyrc file provided by the Perl Best Practices book. Seems a little known option (it's not even in --help output), but something worthwhile knowing. Again, thank you for your excellent response.


Comment on Re^2: Best practices and any way to have Perl Tidy clean it up
Re^3: Best practices and any way to have Perl Tidy clean it up
by kcott (Abbot) on Apr 15, 2013 at 11:25 UTC

    A string (e.g. "a string") is a constant. You can't modify it directly in code. You may well have a very good reason for positioning characters within the string. It would inappropriate for perltidy (or other similar software) to modify a constant you've coded. Even without strict and warnings, attempting to modify a constant value is a fatal error:

    $ perl -e '"abc" =~ s/c$//' Can't modify constant item in substitution (s///) at -e line 1, at EOF Execution of -e aborted due to compilation errors.

    Ditto for numbers:

    $ perl -e '2++' Can't modify constant item in postincrement (++) at -e line 1, near "2 +++" Execution of -e aborted due to compilation errors.

    Chapter 2 of PBP is devoted to Code Layout. While the focus is obviously on laying out Perl code, many of the suggestions would apply equally to other languages: this might provide a few hints for your SQL.

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1028631]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2014-09-23 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (210 votes), past polls