Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Just another Perl shrine
 
PerlMonks  

Re: randomize a text file

by BrowserUk (Pope)
on Jul 17, 2013 at 13:46 UTC ( #1044812=note: print w/ replies, xml ) Need Help??


in reply to randomize a text file

How do you want it randomised?

Given:

a b c d e f g h i j k l m n o p q r s t u v w x y

Do you want (randomise rows; columns stay the same):

k l m n o u v w x y f g h i j p q r s t a b c d e

Or (randomise the columns; rosw stay the same):

c b d e a h g i j f m l n o k r q s t p w v x y u

Or (randomise both):

h g i j f w v x y u c b d e a r q s t p m l n o k

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: randomize a text file
Select or Download Code
Re^2: randomize a text file
by perlnoobster (Sexton) on Jul 17, 2013 at 13:55 UTC
    Hi BrowserUk, I want to randomize the rows, i.e. the columns stay the same, can you help me? thank you
      , can you help me?

      Depends. Post code that reads the file into an array, then maybe.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      If you want to randomize rows only, read your file into an array of rows, apply shuffle from List::Util and print shuffled array into new file. That's all, probably just a one-liner, don't even need to chomp.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-04-24 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (566 votes), past polls