Thanks for the reading suggestions!
Brian Fraser wrote:
On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga
mailto:byu...@langly.dyndns.org>> wrote:
Uri and Jim have hit upon one of my major stumbling blocks with
learning Perl. There seems to be a difference of opinion on the
proper ti
On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga wrote:
> Uri and Jim have hit upon one of my major stumbling blocks with learning
> Perl. There seems to be a difference of opinion on the proper times to use
> hashes vs. arrays/lists...and how best to use them.
http://perldoc.perl.org/perlfaq4.ht
Ben Lavery wrote:
> there must be a slight trade-off... the processing required to
> initialize the hash table with it's keys and values is probably
> more intensive than defining an array with its respective values?
> Unless, internally, Perl stores arrays as hashes, with the indexes
> as the ke
> there must be a slight trade-off... the processing required to initialize the
> hash table with it's keys and values is probably more intensive than defining
> an array with its respective values? Unless, internally, Perl stores arrays
> as hashes, with the indexes as the keys.
I would have
On 9 Mar 2011, at 03:01, Ben Lavery wrote:
> I shall change from a hash to an array and use grep, or looking into it I may
> use List::MoreUtils as it has a "first_value" sub which should make it
> somewhat more efficient.
OK, so about an hour after I wrote this I was on the train home thinking
Jim Gibson wrote:
On 3/9/11 Wed Mar 9, 2011 9:22 AM, "Brian F. Yulga"
scribbled:
>
> foreach ( @word_list ) { if ( /^$temp_word$/i ) { push(
> @all_combinations, ( $_ )); } }
That is pretty much what the grep function is doing. It has to
iterate over the entire array and evaluate its code
On 3/9/11 Wed Mar 9, 2011 9:22 AM, "Brian F. Yulga"
scribbled:
> Uri and Jim have hit upon one of my major stumbling blocks with learning
> Perl. There seems to be a difference of opinion on the proper times to
> use hashes vs. arrays/lists...and how best to use them. For those that
> have he
Uri Guttman wrote:
>> "BL" == Ben Lavery writes:
>
>
> BL> #Here, using a hash looks much cleaner than
iterating through an array
>
> hashes are almost always better for token lookups than scanning
> arrays. don't doubt yourself in this area.
>
>
Jim Gibson wrote:
> On 3/8/
Hi Jim, thanks for replying :)
>>
>> $word_list{$_} = 0;
>
> If you assign 1 to the hash value, you can dispense with the 'exists' in
> your test, below.
>> #Here, using a hash looks much cleaner than iterating through an array
>> push(@all_combinations, $temp_word) if (exists $word_list{$temp_w
On 3/8/11 Tue Mar 8, 2011 2:51 PM, "Ben Lavery"
scribbled:
> Here is my code, I've taken out a few irrelevant bits, but this is the main
> guts:
> use warnings;
> use strict;
> use Math::Combinatorics;
>
> #Set up a hash for searching later
> my %word_list;
>
> #Read list of valid words into
> "BL" == Ben Lavery writes:
BL> use warnings;
BL> use strict;
good!
BL> use Math::Combinatorics;
BL> #Read list of valid words into hash
BL> my $WORDFILE='Words';
BL> open(WORDFILE, "$WORDFILE") or die "can't open $WORDFILE: $!";
BL> while () {
BL> chomp;
BL> $word_l
Hi Rob,
Thank you for your response, sorry it wasn't as clear as I thought it might
have been.
> I have a script, and I want to feed it a special thing to let it know that
> any character (A-Z or a-z does upper lower case matter?) is valid, but I
> also want to use other characters at the same t
Hi Ben,
Not sure I get your point... but this is what it sounds like to me.
I have a script, and I want to feed it a special thing to let it know that
any character (A-Z or a-z does upper lower case matter?) is valid, but I
also want to use other characters at the same time. So ./script.pl -s ABC
13 matches
Mail list logo