You're right, I was thinking of *?
-Original Message-
From: Luke Bakken [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 27, 2002 3:31 PM
To: Timothy Johnson
Subject: RE: Creating a string with quotes and delimiters from an Array
{0,1} is equivalent to ?
On Wed, 27 Feb
On Tue, Feb 26, 2002 at 07:13:52PM -, Angus Laycock wrote:
> I am trying to handle parameters from UNIX that call a PERL script the uses
> DBI, that then calls Sybase stored procedures.
>
> The problem I have found is that they don't pass the strings with single
> quotes and dates are 02-27-
Angus Laycock wrote:
>
> Hi,
Hello,
> 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.
>
> I know I can do this $string = join ( ',' , @array);
> which gives me this >
Wednesday, February 27, 2002 11:11 PM
Subject: RE: Creating a string with quotes and delimiters from an Array
>
> I guess I should have put this: !~ /^[-+]{0,1}\d+(.\d+){0,1}$/ since
> there's really no time that you will need more than one positive or
negative
> in one number.
February 27, 2002 11:14 PM
Subject: Re: Creating a string with quotes and delimiters from an Array
> On Tue, Feb 26, 2002 at 06:07:33PM -, Angus Laycock wrote:
> > I have an array > @array = qw(alf bert charlie 4)
> >
> > and I want a string that contains this value <
&
#x27;Angus Laycock'; Tanton Gibbs; [EMAIL PROTECTED]
Subject: RE: Creating a string with quotes and delimiters from an Array
maybe you can replace =~ /\D/ with "!~ /^[-+]?\d+(.\d+){0,1}$/" *whew*
which means "does not equal:
start with zero or more - or + # ^[-+]?
On Tue, Feb 26, 2002 at 06:07:33PM -, 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
d of the string # (.\d+){0,1}$
-Original Message-
From: Angus Laycock [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 10:41 AM
To: Tanton Gibbs; [EMAIL PROTECTED]
Subject: Re: Creating a string with quotes and delimiters from an Array
What about on negative numbers like -1? Th
Angus Laycock" <[EMAIL PROTECTED]>
To: "Tanton Gibbs" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, February 26, 2002 1:41 PM
Subject: Re: Creating a string with quotes and delimiters from an Array
> What about on negative numbers like -1? They come up w
From: Tanton Gibbs <[EMAIL PROTECTED]>
To: Angus Laycock <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, February 27, 2002 10:30 PM
Subject: Re: Creating a string with quotes and delimiters from an Array
> Your best bet is to do this
= /\D/ ? "'$_'," : "$_,";
> >
> > If you have the time.
> >
> > Thanks again
> >
> > Gus
> >
> >
> > - Original Message -
> > From: Tanton Gibbs <[EMAIL PROTECTED]>
> > To: Angus
it actually expands to
$string = $string . "'$_',";
Hope this helps!
Tanton
- Original Message -
From: "Angus Laycock" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 26, 2002 1:33 PM
Subject: Re: Creating a string with quotes a
ECTED]>
Sent: Wednesday, February 27, 2002 10:30 PM
Subject: Re: Creating a string with quotes and delimiters from an Array
> Your best bet is to do this with a foreach loop
>
> my $string = '';
> my @array = qw( alf bert charlie 4 )
> foreach( @array ) {
> $string
ECTED]>
Sent: Wednesday, February 27, 2002 10:30 PM
Subject: Re: Creating a string with quotes and delimiters from an Array
> Your best bet is to do this with a foreach loop
>
> my $string = '';
> my @array = qw( alf bert charlie 4 )
> foreach( @array ) {
> $string
rings.
Thanks
Gus
- Original Message -
From: Timothy Johnson <[EMAIL PROTECTED]>
To: 'Angus Laycock' <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, February 27, 2002 10:24 PM
Subject: RE: Creating a string with quotes and delimiters from an Array
[EMAIL PROTECTED]>
Sent: Tuesday, February 26, 2002 1:07 PM
Subject: Creating a string with quotes and delimiters from an Array
Hi,
I have an array > @array = qw(alf bert charlie 4)
and I want a string that contains this value < 'alf','bert','charlie&
son
Sent: Wednesday, February 27, 2002 2:23 PM
To: 'Angus Laycock'; [EMAIL PROTECTED]
Subject: RE: Creating a string with quotes and delimiters from an Array
You could try something like this:
foreach(@array){
unless($_ =~ /^\d+$/){
$scalar .= "\'$_\',"; #
-
From: Angus Laycock [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 10:08 AM
To: [EMAIL PROTECTED]
Subject: Creating a string with quotes and delimiters from an Array
Hi,
I have an array > @array = qw(alf bert charlie 4)
and I want a string that contains this value
Hi,
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.
I know I can do this $string = join ( ',' , @array); which gives me this > <
one|two|three|four> but how do I get the si
19 matches
Mail list logo