Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Is Perl scary or is it me?

by FoxtrotUniform (Prior)
on Nov 05, 2004 at 23:30 UTC ( #405665=note: print w/replies, xml ) Need Help??

in reply to Is Perl scary or is it me?

my %hash = map { join(':', $_->{Computer}, $_->{Bulletin}, ( $_->{Product} || "" ), $_->{Status} ) => $_ } @{GetQueryTable('all_records_for_report', 138)};
my %hash; for ( @{GetQueryTable('all_records_for_report', 137)} ) { $hash{"$_->{Computer}:$_->{Bulletin}:" . ($_->{Product}||"") . ":$_->{Status}"} = $_; }

Well, the map-based approach puts the focus on the fact that you're populating %hash. Where you're getting the data from is secondary. The for-based approach puts the focus on the fact that you're doing something with each element in all_records_for_report. What you're doing with it is secondary.

Yours in pedantry,
F o x t r o t U n i f o r m

"Anything you put in comments is not tested and easily goes out of date." -- tye

Replies are listed 'Best First'.
Re^2: Is Perl scary or is it me?
by Golo (Friar) on Nov 06, 2004 at 00:17 UTC

    Good point - I see, I won't get around some comments* :-(

    *comments to where the data comes from, because I think that part is secondary. Now I also know the why :-)

    sub make_lookup { my %hash = map { my $hash = $_; join(':', map { $hash->{$_} || "" } sort(keys(%{$_})) ) => $_ } @_; return \%hash; } my $lookup = make_lookup(@{GetQueryTable('all_records_for_report', 138 +)});

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://405665]
[1nickt]: you are missing an entire element, which is that your base ticket price only gets you a middle seat. If you want to be window or aisle you must pay, or gamble that you'll be assigned there at ...
[1nickt]: ... flihght time (hoping that not enough others have paid and there are some "good" seats to be allotted.
[1nickt]: And this is in addition to paying extra if you want to be in the first 12 rows, or in the emergency exit row.
choroba was once seeted besides a guy that was so fat he was almost squished between the guy
[holli]: I'm surprised there is not an entire genre of "fat guy on a plane" jokes

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-12-18 13:45 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (486 votes). Check out past polls.