> On Dec 8, 2003, at 9:05 AM, Wiggins d Anconia wrote: > > > I did the 'in' function for seeing if one element is inside on list > > like. > >> > >> sub in { > >> my $match = shift; > >> foreach (@_) { > >> return 1 if $match eq $_; > >> } > >> return 0; > >> } > >> > >> so I'm calling the function like > >> > >> if(in($x => (1,2,3))) { > >> ... > >> }; > >> > > > > While I realize your question is more about creating operators, etc. > > Would 'grep' not work the same as the above? > > > > perldoc -f grep > > Well, grep() would be significantly less efficient for huge lists since > it examines all the entries, right? > > James >
Good point, are there internal optimizations based on data that can speed that up? For a huge list, what about memory allocation and resources, I would think at least passing by reference would be a better approach? http://danconia.org -- Boycott the Sugar Bowl! You couldn't pay me to watch that game. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>