Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Skipping Elements in an Array

by vladdrak (Monk)
on Apr 07, 2005 at 08:34 UTC ( [id://445574]=note: print w/replies, xml ) Need Help??


in reply to Skipping Elements in an Array

You could do this:
#!/usr/bin/perl use strict; use Data::Dumper; my @Array = ('AAA','BB','CCCC','DD','EEEEE','FFF','GGGG'); my $num_of_skip =2; for (my $i; $i <= $#Array; $i++) { if (length $Array[$i] == $num_of_skip) { $i=$i+2; } else { print "$Array[$i]\n"; } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-16 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found