in reply to Newline after every 5 periods

perl -p056e '$_ .= "\n" x !(++$c % 5)' text-blob.txt > paragraphs.txt

Replies are listed 'Best First'.
Re^2: Newline after every 5 periods
by paulm2 (Initiate) on Jul 20, 2016 at 12:41 UTC

    Thank you, that works! What's the 0056 doing?

    I'd also like to randomize these paragraph breaks in a range of 5 - 19 periods (not just every n periods), and output to new file. Here's what I've got; the while loop/output isn't right. If it's more appropriate to edit my initial post or make a new post I will. Thanks.

    #!/usr/bin/perl use strict; use warnings; my $filename = 'input.txt'; my $out = 'ouput.txt'; my $minimum = 5; my $range = 19; my $random_number = int(rand($range)) + $minimum; open(my $fh, '>>', $filename) or die "Could not open file '$filename +' $!"; while(my $fh) { print my $fsh('$_.="\n\n" x !(++$c % $random_number')); #compilatio +n error }; close $fh;
      > What's 056 doing?

      See perlrun for the -0 option, and

      perl -wE 'say "\056"' .

      for the meaning of 56.

      ($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,
        thanks! 056 = begins at period alias 0.

      You seem to have changed your post above by deleting some or all of the original question: What's 056 doing?

      This makes choroba's reply seem incoherent at best, since he seems to be answering a question that no one has asked.

      Please don't change or delete material in your posts in a way that destroys context. Please see How do I change/delete my post? to learn the ways of righteous alteration.


      Give a man a fish:  <%-{-{-{-<

        Sorry about that.
Re^2: Newline after every 5 periods
by Anonymous Monk on Jul 20, 2016 at 17:50 UTC

    Can use the $. also. E.g., and not caring for uninitialized warnings:

    perl -p056e '$_ .= ("\n")[$. % 5]'

      Thanks, any suggestion how to implement rand in this statement for \n break within a range of character (.) occurrences?