in reply to Re: DBI and mysql query formatting
in thread DBI and mysql query formatting
"... this will ensure you always have the same order: my @keys = keys %test;"
Actually, that's only true for versions of Perl prior to 5.18.0. From perl5180delta: Hash overhaul:
"By default, two distinct hash variables with identical keys and values may now provide their contents in a different order where it was previously identical."
I have v5.18.1 - here's a few example runs:
$ perl -Mstrict -Mwarnings -E 'my %x = map { $_ => 1 } "A" .. "E"; my +@y = keys %x; say "@y"' A D E C B $ perl -Mstrict -Mwarnings -E 'my %x = map { $_ => 1 } "A" .. "E"; my +@y = keys %x; say "@y"' D E C B A $ perl -Mstrict -Mwarnings -E 'my %x = map { $_ => 1 } "A" .. "E"; my +@y = keys %x; say "@y"' D E B A C
Either a sort on the keys, or even a hard-coded list, would probably provide a more robust solution.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: DBI and mysql query formatting
by tangent (Parson) on Dec 06, 2013 at 11:20 UTC | |
by afoken (Chancellor) on Dec 08, 2013 at 14:37 UTC | |
by tangent (Parson) on Dec 08, 2013 at 18:38 UTC |