in reply to searching in large file

If i guessed your specs right you are after an intersection.

Hence something like this using Set::Scalar and Path::Tiny might be a way to go:

#!/usr/bin/env perl use strict; use warnings; use Set::Scalar; use Path::Tiny; use Data::Dump; use feature qw (say); say path("file01.txt")->slurp_utf8; say path("file02.txt")->slurp_utf8; my @s = path("file01.txt")->lines_utf8( { chomp => 1 } ); my @t = path("file02.txt")->lines_utf8( { chomp => 1 } ); dd \@s; dd \@t; my $s = Set::Scalar->new(@s); my $t = Set::Scalar->new(@t); my $i = $s->intersection($t); say $i; path("out.txt")->spew_utf8( map { "$_\n" } @$i ); print path("out.txt")->slurp_utf8; __END__ karls-mac-mini:sabas karl$ ./sabas.pl foo bar donald nose cuke donald ["foo", "bar", "donald"] ["nose", "cuke", "donald"] (donald) donald

OK, admittedly very simplified. And 300K isn't really large IMHO. Threads From Hell #2: How To Search A Very Huge File [SOLVED] might probably also be of interest. If you want to get rid of this @ARGV stuff see Re: GetOpt Organization. Some might say that i repeat myself ;-)

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

perl -MCrypt::CBC -E 'say Crypt::CBC->new(-key=>'kgb',-cipher=>"Blowfish")->decrypt_hex($ENV{KARL});'Help