Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Sorting Days of Week Using today () to today () + 6

by MidLifeXis (Monsignor)
on Jul 10, 2013 at 17:21 UTC ( #1043507=note: print w/replies, xml ) Need Help??

in reply to Sorting Days of Week Using today () to today () + 6

Just a couple of comments:

  • WHERE calendar_desc = '$voy_cal2use': Use What are placeholders in DBI, and why would I want to use them? instead.
  • I could not find a declaration for $voy_cal2use.
  • There is a lot of duplicated code. Quite a bit could be reduced by generating part of the SQL:
    my $column_names = join( ",", map { ( "${_}_open", "${_}_openhour", "${_}_closehour" ); } map { lc( $_ ); } @day_text; my $sql = qq(SELECT $column_names ...);
  • I would probably use a slightly different data structure and leverage the bind_col or bind_columns call from DBI instead of the block of $normal_hrs{$day}{$subkey} = ... calls.

No time yet to evaluate other things.


Replies are listed 'Best First'.
Re^2: Sorting Days of Week Using today () to today () + 6
by Hans Castorp (Sexton) on Jul 10, 2013 at 18:22 UTC

    Many thanks MidLifeXis for your teaching-based response--there is much to think about here.

    I did not include all the code because it's over 200 lines long--the declaration for $voy_cal2use is above the snippet I posted.

    Still very new to Perl (and any programming), so although I know "There is more than one way to do it," I am very hesitant to mess with my predecessor's code. I've thought many times that it might be easier to write my own script, but I don't know enough to do that yet. Thanks for the introduction to more streamlined possibilities--and the humor. :-) I will play with the SQL.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043507]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2018-05-24 20:24 GMT
Find Nodes?
    Voting Booth?