Vince75 has asked for the wisdom of the Perl Monks concerning the following question:
I know that is a VERY basic question, but I am working on it since this morning and it is driving me made. But since "the more time you spend on a problem, the more stupid is this problem", I realise the solution might be very simple.
Here is the code of my cgi script :
#!usr/bin/perl use CGI; $res = "aaaaubbbbuooooo"; @rest = split /u/,$res; $restLength = length(@rest); print "Content-type: text/html\n\n"; print "restLength : $restLength"; for ($i=0;$i<length(@rest);$i++){ print "@rest[$i]"; }
My browser print :
restLength : 1
aaaa
Why does it not print :
restLength : 3
aaaa
bbbb
ooooo
Why why why why ????
thxjanitored by ybiC: Balanced <code> tags, minor format cleanup
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Basic question about split
by Enlil (Parson) on Dec 12, 2003 at 23:29 UTC | |
by jweed (Chaplain) on Dec 13, 2003 at 02:12 UTC | |
|
Re: Basic question about split
by Anonymous Monk on Dec 12, 2003 at 23:32 UTC | |
by Vince75 (Initiate) on Dec 12, 2003 at 23:40 UTC | |
by flyingmoose (Priest) on Dec 13, 2003 at 01:21 UTC | |
|
Re: basic question on split
by simonm (Vicar) on Dec 12, 2003 at 23:37 UTC | |
|
Re: Basic question about split
by Zaxo (Archbishop) on Dec 12, 2003 at 23:41 UTC | |
|
Re: basic question on split
by flyingmoose (Priest) on Dec 12, 2003 at 23:59 UTC | |
|
Re: basic question on split
by CountZero (Bishop) on Dec 13, 2003 at 10:42 UTC | |
|
Re: basic question on split
by Nkuvu (Priest) on Dec 12, 2003 at 23:42 UTC |