Unsort Lines BBEdit Unix Filter


/ Published in: Perl
Save to your folder(s)

Need to "unsort" / randomize / scramble LINES in a text? Copy source -> then BBEdit -> File -> New -> Text Document -> paste source -> save as "Unsort Lines.pl" to ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/ --- done


Copy this code and paste it in your HTML
  1. #!/usr/bin/perl -wl
  2.  
  3. @f=<>;
  4.  
  5. for $i (0 .. $#f) {
  6. $r=int rand ($i+1);
  7. @f[$i, $r]=@f[$r,$i] if ($i!=$r);
  8. }
  9.  
  10. chomp @f;
  11.  
  12. print join $/, @f;

URL: http://www.commandlinefu.com/commands/view/4401/randomize-lines-opposite-of-sort

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.