Re: White space split

2007-09-20 Thread Rob Dixon
yitzle wrote: --- yitzle <[EMAIL PROTECTED]> wrote: Note: split splits on whitespace by default, so these two are the same: split /\s+/, @array; split @array; Technically, the two /are/ the same, and my point is valid. The fact that I used an array instead of a string was a mistake. I blame

Re: White space split

2007-09-20 Thread yitzle
--- yitzle <[EMAIL PROTECTED]> wrote: > Note: split splits on whitespace by default, so these two are the same: > split /\s+/, @array; > split @array; Technically, the two /are/ the same, and my point is valid. The fact that I used an array instead of a string was a mistake. I blame it on the lack

Re: White space split

2007-09-20 Thread John W. Krahn
[EMAIL PROTECTED] wrote: --- yitzle <[EMAIL PROTECTED]> wrote: Note: split splits on whitespace by default, so these two are the same: split /\s+/, @array; split @array; Not right.You split a string,not an array or a list. all below are wrong: It depends what you mean by "wrong". split @

Re: White space split

2007-09-20 Thread Rob Dixon
yitzle wrote: Note: split splits on whitespace by default, so these two are the same: split /\s+/, @array; split @array; Not true: use strict; use warnings; my @list; for (' A B C ') { @list = split /\s+/, $_; print scalar @list, "\n"; @list = split; print scalar @list, "\n"; } **OUT

Re: RE: White space split

2007-09-20 Thread Chas Owens
On 9/20/07, Dr.Ruud <[EMAIL PROTECTED]> wrote: > Andrew Curry schreef: > > > (split/\s+/,$cmd) > > Very often, (split ' ', $cmd) is the better alternative. snip For the uninitiated: split ' ', $string does what split /\s+/, $string does, but also removes leading whitespace. The following code pri

Re: RE: White space split

2007-09-20 Thread Dr.Ruud
Andrew Curry schreef: > (split/\s+/,$cmd) Very often, (split ' ', $cmd) is the better alternative. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: White space split

2007-09-20 Thread John W. Krahn
yitzle wrote: Note: split splits on whitespace by default, so these two are the same: split /\s+/, @array; split @array; $ perl -le' @array = "a" .. "z"; $_ = "@{[ 10 .. 40 ]}"; print for split /\s+/, @array; ' 26 split /\s+/, @array; Is the same as: split /\s+/, '26', 0; $ perl -le' @ar

Re: RE: White space split

2007-09-20 Thread useperl-jeff
--- yitzle <[EMAIL PROTECTED]> wrote: > Note: split splits on whitespace by default, so these two are the same: > split /\s+/, @array; > split @array; > Not right.You split a string,not an array or a list. all below are wrong: split @array; split (11,22,33); split $string; see `perldoc -f spli

Re: RE: White space split

2007-09-20 Thread yitzle
Note: split splits on whitespace by default, so these two are the same: split /\s+/, @array; split @array; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: RE: White space split

2007-09-20 Thread manojkumarg
Yep...I got it !! .. - Original Message - From: [EMAIL PROTECTED] Date: Thursday, September 20, 2007 5:44 pm Subject: Re: RE: White space split To: [EMAIL PROTECTED], Andrew Curry <[EMAIL PROTECTED]> Cc: beginners@perl.org > --- [EMAIL PROTECTED] wrote: > > >

RE: RE: White space split

2007-09-20 Thread Andrew Curry
Try my $cmd1 = (split/\s+/,$cmd)[0]; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 20 September 2007 13:04 To: [EMAIL PROTECTED]; Andrew Curry Cc: beginners@perl.org Subject: Re: RE: White space split --- [EMAIL PROTECTED] wrote: > Thanks Andrew

Re: RE: White space split

2007-09-20 Thread useperl-jeff
--- [EMAIL PROTECTED] wrote: > Thanks Andrew and Jeff. > ($cmd1, $rest)=split/\s+/,cmd$; worked for me. > my ($cmd1) = split/\s+/,$cmd; is still giving me the length... > I wanted to use something like above ... you may type something wrong?see the test, $ cat t3.pl my $cmd = "maheshverama

Re: RE: White space split

2007-09-20 Thread manojkumarg
<[EMAIL PROTECTED]> Date: Thursday, September 20, 2007 5:33 pm Subject: RE: White space split To: [EMAIL PROTECTED], beginners@perl.org > Split returns an array > So you need to do something like > > #!/bin/perl > $cmd="maheshverama #XX#&q

RE: White space split

2007-09-20 Thread Andrew Curry
Appologies typo, I know the difference thanks. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 20 September 2007 12:57 To: beginners@perl.org Subject: RE: White space split --- Andrew Curry <[EMAIL PROTECTED]> wrote: > Split returns an array retur

RE: White space split

2007-09-20 Thread useperl-jeff
--- Andrew Curry <[EMAIL PROTECTED]> wrote: > Split returns an array returns a list not array. see `perldoc -q "What is the difference between a list and an array?"` Sick of deleting your inbox? Yahoo

RE: White space split

2007-09-20 Thread Andrew Curry
tember 2007 12:56 To: beginners@perl.org Subject: White space split Hello, I am trying to do this #!/bin/perl $cmd="maheshverama #XX#"; $cmd1=split /\s+/,$cmd; print $cmd1; Wanted the first part to be taken its giving me some numbers as output. Thanks Ma

Re: White space split

2007-09-20 Thread useperl-jeff
--- [EMAIL PROTECTED] wrote: > Hello, > > I am trying to do this > > #!/bin/perl > $cmd="maheshverama #XX#"; > $cmd1=split /\s+/,$cmd; > print $cmd1; > > Wanted the first part to be taken its giving me some numbers as output. > Hello, because split return a lis

White space split

2007-09-20 Thread manojkumarg
Hello, I am trying to do this #!/bin/perl $cmd="maheshverama #XX#"; $cmd1=split /\s+/,$cmd; print $cmd1; Wanted the first part to be taken its giving me some numbers as output. Thanks Manoj -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-m