Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

array problem
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

Report this thread to moderator Post Follow-up to this message
Old Post
Mo
07-30-04 01:55 PM


Re: array problem
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

Report this thread to moderator Post Follow-up to this message
Old Post
Joe Smith
07-30-04 01:55 PM


Re: array problem
Dear Mo -
 

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

Report this thread to moderator Post Follow-up to this message
Old Post
William Goedicke
07-30-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Programming archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:30 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.