Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: searching through data

by dreadpiratepeter (Priest)
on Apr 16, 2009 at 12:19 UTC ( [id://757959]=note: print w/replies, xml ) Need Help??


in reply to searching through data

I would use a hash, like so (untested code warning):
use strict; use warnings; my @array; # contains numbers (1..1000000) ~ 400000 numbers my %hash; open (in , "<", "in.txt") || die "$!"; while(<in>){ m/^(\d+)/; $hash{$1} = 1; } close in; foreach my $num (@array) { print "$num, " if exists $hash{$num}; }


-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-20 00:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found