Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

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

by MidLifeXis (Prior)
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': http://www.bobby-tables.com. 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.

--MidLifeXis


Comment on Re: Sorting Days of Week Using today () to today () + 6
Select or Download Code
Re^2: Sorting Days of Week Using today () to today () + 6
by Hans Castorp (Acolyte) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043507]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2014-12-21 14:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls