Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The formatting of the code/data and intent was hard for me to understand. But maybe this works for you?:
#!/usr/bin/perl -w use strict; use Data::Dumper; # a core utility use List::Util qw(shuffle); # a core utility my @data; while (<DATA>) { next if /^\s*$/; #skip blank lines my ($important) = (split(' ',$_))[0]; push @data, $important; } print Dumper \@data; #debug - just to verify the split() # so @data is about 100,000 entries # this is a big array, but not that big # the use of splice() works, but is relatively inefficient # perhaps just use List::Util shuffle to randomize the # indicies? # This will create a list with 100,000 values # but it will do it efficiently. # Within the parameters of what you have said, # 1/4 million array/list elements will work ok, even on # my wimpy Win XP32 bit machine foreach my $index (shuffle (0..@data-1)) { print "$index $data[$index]\n"; } =prints VAR1 = [ 'FRZPY5Q02F00L9.ICM_AWP_Bv6.AWP_0001_2007_08_23', 'FRZPY5Q02F00U8.ICM_AWP_Bv6.AWP_0001_2007_08_23', 'FRZPY5Q02F01NC.ICM_AWP_Bv6.AWP_0001_2007_08_23', 'FRZPY5Q02F023C.ICM_AWP_Bv6.AWP_0001_2007_08_23' ]; 3 FRZPY5Q02F023C.ICM_AWP_Bv6.AWP_0001_2007_08_23 2 FRZPY5Q02F01NC.ICM_AWP_Bv6.AWP_0001_2007_08_23 1 FRZPY5Q02F00U8.ICM_AWP_Bv6.AWP_0001_2007_08_23 0 FRZPY5Q02F00L9.ICM_AWP_Bv6.AWP_0001_2007_08_23 =cut __DATA__ FRZPY5Q02F00L9.ICM_AWP_Bv6.AWP_0001_2007_08_23 ACTGCCAACGCGCAGAACCTTAC +CAGGTCCTGACTTCCTGACTATGGTTATTAGAAATAA TTTCCTTCAGTTCGGCTGGGTCAGTGACAGG +TGATGCATGGCCGTC FRZPY5Q02F00U8.ICM_AWP_Bv6.AWP_0001_2007_08_23 ACTGCCTAACCGATGAACCTTAC +CTACACTTGACATGCAGAGAACTTTCCAGAGATGGAT TGGTGCCTTCGGGAACTCTGACACAGGTGAT +GCATCGCCGTC FRZPY5Q02F01NC.ICM_AWP_Bv6.AWP_0001_2007_08_23 ACTGCCTACGCGAAGAACCTTAC +CTACACTTGACATACAGAGAACTTACCAGAGATGGTT TGGTGCCTTCGGGAACTCTGATACAGGTGAT +GCATGGCTGTC FRZPY5Q02F023C.ICM_AWP_Bv6.AWP_0001_2007_08_23 ACTGCCAACGCGCAGAACCTTAC +CAACCCTTGACATCCAGAGAATTTTCTAGAGATAGAT TTGTGCCTTCGGGAACTCTGTGACAGGTGAT +GCATGGCTGTC

In reply to Re: Get random unique lines from file by Marshall
in thread Get random unique lines from file by radnorr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found