Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Join question

by Dandello (Monk)
on May 02, 2012 at 22:04 UTC ( #968564=perlquestion: print w/replies, xml ) Need Help??

Dandello has asked for the wisdom of the Perl Monks concerning the following question:

I've been working with someone else's code and came across this to generate a mySQL command:

 mysql_process( 0, 'do', qq~DELETE FROM `$db_table{$DBfile}[0]` WHERE `$db_table{$DBfile}[1]`="~ . join( '" OR `$db_table{$DBfile}[1]`="', @where ) . q~"~ );

Now, my gut tells me the section of code inside the join for the delimiter should be interpolated not a literal. But I'd like a second or third opinion.

Replies are listed 'Best First'.
Re: Join question
by JavaFan (Canon) on May 02, 2012 at 22:36 UTC
    Instead of asking our opinion, why don't you just print out the result of the concat and the join, and see whether it makes sense? And if it doesn't, see whether it makes sense when you interpolate it.

    I think that's much easier than posting a question ;-)

      It didn't make a lot of sense but it also seemed to be working in the application in a test setting.

Re: Join question
by sauoq (Abbot) on May 02, 2012 at 22:16 UTC
    Now, my gut tells me the section of code inside the join for the delimiter should be interpolated not a literal.

    It won't be interpolated. It is enclosed in single quotes.

    Update: Oh, I guess you are asking whether it was meant to be interpolated? Yes, I think that was the intent.

    "My two cents aren't worth a dime.";
Re: Join question
by bobf (Monsignor) on May 03, 2012 at 01:58 UTC

    I would have expected it to be interpolated, but it is hard to say it is incorrect (especially if it was working in a test environment) without knowing what mysql_process does. Is there an eval in that routine?

      There's no eval in mysql_processes. I'm coming to the conclusion that the input to mysql_processes looks like it's working because @where is empty on the test app. I'll add more for it to work on tomorrow and see what happens - but I'm betting it should be interpolated.

      In the meantime, thanks everybody for looking at it and giving your input.

Re: Join question
by Dandello (Monk) on May 02, 2012 at 22:22 UTC

    I know it currently isn't being interpolated, but based on the rest of the code, I'm thinking it's wrong that it's written not to be interpolated. Does that make sense?

      Yes, I agree with you.

      I was updating my answer as you replied.

      "My two cents aren't worth a dime.";

        Thank you - if it were my own code, I wouldn't need to ask as I would (hopefully) know what I was trying to do. VBG

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://968564]
Approved by BrowserUk
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2023-03-30 17:33 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (74 votes). Check out past polls.