The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
perl -write values in a file to @array in perl meghana Shell Programming and Scripting 27 06-07-2009 06:05 PM
A final question! Compare character with each array element rorey_breaker Shell Programming and Scripting 1 09-28-2007 10:26 AM
array type has incomplete element type jaganadh High Level Programming 1 07-24-2007 04:54 AM
Perl delete an element from array ahtat99 Shell Programming and Scripting 6 01-18-2007 09:25 AM
accessing my first element of array afadaghi Shell Programming and Scripting 4 09-29-2005 05:43 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2008
chriss_58 chriss_58 is offline
Registered User
  
 

Join Date: May 2008
Posts: 41
Remove an element from an array in PERL

Hello guys,

I have the following question.

Consider the following code in PERL


Code:
for($xeAnumber=0; $xeAnumber<@xeAnumber; $xeAnumber++)
           {
              if(@xeAnumber[$xeAnumber]==@final_file[2])
              {
                 @final_file[0]=@xeTimeStamp[$xeAnumber];
                 
              }

What i want to do is that when the if statement is met how can i remove from the array @xeAnumber the element @xeAnumber[$xeAnumber]????

Thank you.

Last edited by Yogesh Sawant; 06-04-2008 at 07:58 AM.. Reason: added code tags
  #2 (permalink)  
Old 06-04-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
you can remove an element of an array using splice function
  #3 (permalink)  
Old 06-06-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Also note that when referring to an element in an array, the syntax is $array[$n] not @array[$n]

... and Perl is a name, not an acronym.
  #4 (permalink)  
Old 06-06-2008
summer_cherry summer_cherry is offline Forum Advisor  
Registered User
  
 

Join Date: Jun 2007
Location: Beijing China
Posts: 1,089
just use


Code:
delete $arr[$index]

Closed Thread

Bookmarks

Tags
perl array, perl splice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0