Re: Converting a list join to a scaler/string
From: J. Gleixner (glex_nospam_at_qwest.invalid)
Date: 11/06/03
- Next message: sdfgsd: "Re: Converting a list join to a scaler/string"
- Previous message: Chris Mattern: "Re: what language is this?"
- In reply to: sdfgsd: "Re: Converting a list join to a scaler/string"
- Next in thread: sdfgsd: "Re: Converting a list join to a scaler/string"
- Reply: sdfgsd: "Re: Converting a list join to a scaler/string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 06 Nov 2003 10:34:45 -0600
sdfgsd wrote:
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:bodl1l$n2$1@mamenchi.zrz.TU-Berlin.DE...
>
>>sdfgsd <footnipple@indiatimes.com> wrote in comp.lang.perl.misc:
>
>
> <snip>
>
>>>The comma could not be stripped from the string produced by the join
>>
>>Of course not. Remember how you built the string? The parts were
>>
>> my @quoted = map {"'$_', "} @fields;
>>
>>These all end with a comma *and a blank*, and so does the joined string
>>you build from them. No mystery at all.
>>
>>Anno
>>
>
>
> OH Jeez!! Thanks.
Now that you've stated you're trying to build SQL, there are better ways
to do what you want. Read a few of the many articles at:
http://www.perl.com/search/index.ncsp?sp-q=dbi&submit=Search
For instance:
http://www.perl.com/pub/a/2001/03/dbiokay.html
my $fields = join(', ', @fields);
my $values = join(', ', map { $dbh->quote($_) } @formdata{@fields});
my $sql = "INSERT into $table ($fields) values ($values)";
Can also use placeholders, and not have to worry about calling quote
directly, to make things even nicer. That's also covered in that article.
- Next message: sdfgsd: "Re: Converting a list join to a scaler/string"
- Previous message: Chris Mattern: "Re: what language is this?"
- In reply to: sdfgsd: "Re: Converting a list join to a scaler/string"
- Next in thread: sdfgsd: "Re: Converting a list join to a scaler/string"
- Reply: sdfgsd: "Re: Converting a list join to a scaler/string"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|