Re: Split function
- From: mritty@xxxxxxxxx (Paul Lalli)
- Date: Tue, 30 Oct 2007 06:34:05 -0700
On Oct 30, 5:37 am, isa...@xxxxxxxxx (Irfan Sayed) wrote:
Hi All,
I have one variable which stores the value as follows.
"2007-09-07T12:50:26+05:30 aic_8.0_Integration ccvob01" Now my
requirement is that I want to store aic_8.0_Integration part of the
string in different variable.
so what I did was I ran following code.
chomp(my @strm = split(/ /, $IntegrationStream)); where
$IntegrationStream stores the above string.
But the issue is that when I try to access $strm[1] , I am not getting
expected result. i.e. aic_8.0_Integration
Can you please guide me how should I achieve this.
Annoyingly,
split / /, $foo;
and
split ' ', $foo;
are not the same thing. split ' ', $foo is a special case that means
to split on all sequences of whitespace. It means the same thing as
split /\s+/, $foo; In your statement, you're only splitting on a
single whitespace character. There are two spaces in your string, so
you're getting a null string as the second element of the returned
list, since there is a "nothing" in between the two space characters.
Paul Lalli
.
- Follow-Ups:
- Re: Split function
- From: Rob Dixon
- Re: Split function
- References:
- Split function
- From: Irfan Sayed
- Split function
- Prev by Date: Re: perl with mysql which takes a file as a input that contains the info to create the tables
- Next by Date: Re: Include variables from external perl script
- Previous by thread: Split function
- Next by thread: Re: Split function
- Index(es):
Relevant Pages
|