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
--- 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
[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 @
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
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
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/
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
--- 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
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/
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:
>
> >
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
--- [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
<[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
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
--- 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
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
--- [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
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
18 matches
Mail list logo