|
|
|
|
Hi
I have an array that consists of
@array = ('The amount of apples I have is 10')
I want to be abe to delete 'The amount of apples I have is' from the
array so I am left with
@array = ('10').
I have tried to use splice but it does seem to do what I want.
Any tips on how to do this would be great.
M
| |
| Joe Smith 2004-07-30, 8:55 am |
| Mo wrote:
> I have an array that consists of
> @array = ('The amount of apples I have is 10')
You have an array that contains a single element; a string of length 33.
> I want to be abe to delete 'The amount of apples I have is' from the
> array so I am left with
>
> @array = ('10').
You want to delete part of the string such that the remaining string
has a length of two characters.
> I have tried to use splice but it does seem to do what I want.
Of course not. Use splice() when there is more than one element in
the array. Use substr($array[0]) or $array[0]=~s/....// to change
the string.
-Joe
| |
| William Goedicke 2004-07-30, 3:56 pm |
| Dear Mo -
[color=darkred]
Mo> @array = ('The amount of apples I have is 10')
Mo> I want to be abe to delete 'The amount of apples I have is'
Mo> from the array so I am left with
Mo> @array = ('10').
As stated you'ld be better off with an array of 8 things
rather than an array of 1 long thing.
@array = qw( The amount of apples I have is 10 );
Then it's easy.
$ten = $array[-1];
Yours - Billy
========================================
====================
William Goedicke goedicke@goedsole.com
Cell 617-510-7244 http://www.goedsole.com:8080
========================================
====================
Lest we forget:
Politically I sit in that middle ground between Fidel Castro
and the hardcore anarchists.
- William Goedicke
|
|
|
|