Re: combining array to scalar

2003-07-02 Thread Rob Dixon
Jenda Krynicky wrote: > Date sent: Tue, 1 Jul 2003 00:56:10 -0700 (PDT) > From: "Ling F. Zhang" <[EMAIL PROTECTED]> > Send reply to: [EMAIL PROTECTED] > Subject: combining array to scalar > To: [EMAIL PROTECTED] > > > sa

Re: combining array to scalar

2003-07-02 Thread Jenda Krynicky
From: "John W. Krahn" <[EMAIL PROTECTED]> > Jenda Krynicky wrote: > > > > Assuming you meant > > > > @a=("I","LOVE","PERL"); > > > > $b = join(' ', map {ucfirst(lc($_))} @a) . "\n"; > > $b = qq<@{[map"\u\L$_",@a]}\n>; # :-) ($b=lc"@a\n")=~s/\b(.)/\U$1/g; or ($b="[EMAIL PROTECTED]")

Re: combining array to scalar

2003-07-02 Thread John W. Krahn
Jenda Krynicky wrote: > > Assuming you meant > > @a=("I","LOVE","PERL"); > > $b = join(' ', map {ucfirst(lc($_))} @a) . "\n"; $b = qq<@{[map"\u\L$_",@a]}\n>; # :-) > print $b; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comm

Re: combining array to scalar

2003-07-02 Thread Jenda Krynicky
Date sent: Tue, 1 Jul 2003 00:56:10 -0700 (PDT) From: "Ling F. Zhang" <[EMAIL PROTECTED]> Send reply to: [EMAIL PROTECTED] Subject: combining array to scalar To: [EMAIL PROTECTED] > say I have array: >

Re: combining array to scalar

2003-07-01 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Steve Grazzini wrote: > On Tue, Jul 01, 2003 at 11:40:55AM +0200, Kevin Pfeiffer wrote: >> I tried a couple more variations - and wonder why the last >> one doesn't evaluate a count of the slice... > > I think this is interesting: > >> $string = @array[0..1]; >>

Re: combining array to scalar

2003-07-01 Thread Sudarshan Raghavan
Steve Grazzini wrote: On Tue, Jul 01, 2003 at 03:43:31PM +0530, Sudarshan Raghavan wrote: array vs list, an array in a scalar context evaluates to the number of elements in it. The same does not apply to a list, infact I don't think there is a list in scalar context. Yep. "There is no l

Re: combining array to scalar

2003-07-01 Thread Steve Grazzini
On Tue, Jul 01, 2003 at 03:43:31PM +0530, Sudarshan Raghavan wrote: > array vs list, an array in a scalar context evaluates to the > number of elements in it. The same does not apply to a list, > infact I don't think there is a list in scalar context. Yep. "There is no list... " > my $string =

Re: combining array to scalar

2003-07-01 Thread Ling F. Zhang
int $i; > > > - Original Message - > From: "Ling F. Zhang" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, July 01, 2003 4:56 PM > Subject: combining array to scalar > > > > say I have array: > > @a=[&

Re: combining array to scalar

2003-07-01 Thread Steve Grazzini
On Tue, Jul 01, 2003 at 11:40:55AM +0200, Kevin Pfeiffer wrote: > I tried a couple more variations - and wonder why the last > one doesn't evaluate a count of the slice... I think this is interesting: > $string = @array[0..1]; > print "$string\n"; > # prints "oranges" (why not "2"?) Do you exp

Re: combining array to scalar

2003-07-01 Thread Sudarshan Raghavan
Kevin Pfeiffer wrote: In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: Ling F. Zhang wrote: say I have array: @a=["I","LOVE","PERL"] [...] This will do what you want my $arr_to_str = "@a"; [...] Wow! I tried a couple more variations - and wonder why the last

Re: combining array to scalar

2003-07-01 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Sudarshan Raghavan wrote: > Ling F. Zhang wrote: > >>say I have array: >>@a=["I","LOVE","PERL"] [...] > This will do what you want > my $arr_to_str = "@a"; [...] Wow! I tried a couple more variations - and wonder why the last one doesn't evaluate a count of the

Re: combining array to scalar

2003-07-01 Thread Sudarshan Raghavan
Ling F. Zhang wrote: say I have array: @a=["I","LOVE","PERL"] You have created a reference to an anonymous array here, I guess you meant @a = qw/I LOVE PERL/; I would like to make a scalar: $b="I Love Perl\n" Please don't name variables as $b etc, they make the code unreadable and read through

Re: combining array to scalar

2003-07-01 Thread PANNEER SELVAN
Is this okay? @a=("I","LOVE","PERL"); $i=join(" ",@a); print $i; - Original Message - From: "Ling F. Zhang" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, July 01, 2003 4:56 PM Subject: combining array to scalar

combining array to scalar

2003-07-01 Thread Ling F. Zhang
say I have array: @a=["I","LOVE","PERL"] I would like to make a scalar: $b="I Love Perl\n" can I do this with a simple one-liner? __ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For a