On Tue, Feb 26, 2002 at 06:07:33PM -0000, Angus Laycock wrote: > I have an array ----> @array = qw(alf bert charlie 4) > > and I want a string that contains this value < 'alf','bert','charlie','4' > > with the single quotes and commas. $str = join(',', map { "'$_'" } @array); > Also, how can I check if one of the values is numeric so I dont put quotes > around it? So the result is like this ---> < 'alf','bert','charlie',4 > $str = join(',', map { /\D/ ? "'$_'" : $_ } @array); "value is numeric" is a little vague; I went with a regex that's simple, but won't catch quite a few variations. See perldoc -q 'is a number' for alternatives. By the way, what is this for? It looks suspiciously like you're using it for database inserts or something along those lines; there are better alternatives if that is the case. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com --Thread Previous | Thread Next