Perl Basics
Introduction to Perl
FAQ's
CGI
Regular Expressions

PC Overview
Cool Stuff
My Modules
Success Stories
Links
Perl in the News
Logos
Perl @ msn
Perl Chat

PC Internals
About
Contact
Guest Book
Handy Logos
What's new

Arrays

See also Loop Processing
P-friendly

[ home ] - [ search ] - [ sitemap ]

#!/usr/bin/perl -w
use strict;

my @links = ('xbc', 'def', 'ghi', 'ZZZ', 'xzz');
my $i = 0;

for (0 .. $#links) {
        print $links[$i++], "\n";
}

@links = sort @links;
print "\n";

for ($i = 0; $i< $#links +1; $i++) {
        print $links[$i], "\n";
}

WORKLOOP: while (my $link = shift @links) {

        for (my $i = 0; $i< $#links; $i++) {
                next WORKLOOP if $link eq 'ZZZ';
        }
        print ">>>>> working on $link\n";
}

Output would be:

xbc
def
ghi
ZZZ
xzz

ZZZ
def
ghi
xbc
xzz

>>>>> working on def
>>>>> working on ghi
>>>>> working on xbc
>>>>> working on xzz
home - feedback - search - web jobs
© 1998-2004 retoh :)