in reply to Re^3: Text::CSV not able to execute insert query dynamically.
in thread Text::CSV not able to execute insert query dynamically.

Hi..sorry for late reply..was off work :) Thanks a lot..It works perfectly. But could you please explain it little further...how u used do block? Thanks again..:)

  • Comment on Re^4: Text::CSV not able to execute insert query dynamically.

Replies are listed 'Best First'.
Re^5: Text::CSV not able to execute insert query dynamically.
by kennethk (Abbot) on Sep 24, 2014 at 15:53 UTC
    A do block just executes the contained code and returns the last thing that was evaluated. In this context, I use it to create a tight scope for the $count and $qs variables. It is functionally equivalent to
    my $count = @$columns; my $qs = join ',', ('?') x $count; my $sql = <<EOSQL; INSERT INTO VoucherMRPDataTable_Frt_TariffModel VALUES ($qs) EOSQL
    except that in the latter case, you'll be carrying around two more variables, one of which has a very generic name.

    Does that clarify things?


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.