Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Perltidy: an option to keep sub($args){} as a single line?

by alexbyk (Novice)
on Jun 16, 2016 at 21:08 UTC ( [id://1165909]=perlquestion: print w/replies, xml ) Need Help??

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

$fs->traverse('/foo')->filter(sub ($name, $dir) { $name !~ /^\./; }); $fs->traverse('/foo')->filter(sub { $_[0] !~ /^\./; });
Is there any option to keep the first line as is? Because with -pbp perltidy breaks it into 5 lines because of a signatures feature.

UPD: the answer is -fnl http://stackoverflow.com/a/37872291/1198451

Replies are listed 'Best First'.
Re: Perltidy: an option to keep sub($args){} as a single line?
by runrig (Abbot) on Jun 16, 2016 at 22:53 UTC
    Really? I don't get that. What version of perltidy? I get this with both v20120714 and v20160302
    $fs->traverse('/foo')->filter( sub ($name, $dir) { $name !~ /^\./; } ) +; $fs->traverse('/foo')->filter( sub { $_[0] !~ /^\./; } ) +;
Re: Perltidy: an option to keep sub($args){} as a single line?
by choroba (Cardinal) on Jun 16, 2016 at 21:26 UTC
    Crossposted to StackOverflow. Crossposting is OK, but it's considered polite to inform about it in order to protect people not visiting both sites from wasting their efforts hacking a solution to a problem already solved at the other end of the internet.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
      Roger that. Thanks
Re: Perltidy: an option to keep sub($args){} as a single line?
by runrig (Abbot) on Jun 17, 2016 at 16:09 UTC
    Looks like there were changes in the latest version that may fix signature problems in the previous version (i.e., try upgrading?):
    Perltidy Change Log 2016 03 02 - RT #112534. Corrected a minor problem in which an unwanted new +line was placed before the closing brace of an anonymous sub with a signature, if it was in a list. Thanks to Dmytro Zagashev. - Corrected a minor problem in which occasional extra indentatio +n was given to the closing brace of an anonymous sub in a list when +the -lp parameter was set. 2016 03 01 - RT #104427. Added support for signatures.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 23:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found