ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-users
perl-win32-users
Removing entries from an array
by Jim Hill other posts by this author
Dec 31 2003 4:41AM messages near this date
view in the new Beta List Site
Re: Perl/Tk book | Re: Removing entries from an array
Whilst looping through an array, how do I remove the current
entry?

 my @array = qw (one two two three four);
 foreach (@array) {
     if (/two/) {
         print "$_\n";
         shift @array;
     }
 }
 print "@array\n";

I'm trying to remove both of the "two" entries from the array so
that the printed output becomes ...

two
two
one three four

I know I can do it by pushing the wanted items into a new array
but the real array is rather large and I'd rather not do that
merely to remove two small entries if at all possible.
-- 

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Jim Hill
Rob Dixon
Hu Guoxin
Rob Dixon
Jim Hill
Randy W. Sims
Eric Edwards
Sisyphus
$Bill Luebkert
Jim Hill
$Bill Luebkert
Jim Hill
$Bill Luebkert

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved