Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Manipulating Array Indexes

by tybalt89 (Prior)
on Sep 08, 2020 at 13:31 UTC ( #11121485=note: print w/replies, xml ) Need Help??


in reply to Manipulating Array Indexes

No need to bother with indexes...

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11121442 use warnings; my @data = qw( 1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 ); my $target = 5; my $want = 0; for ( @data ) { $want-- > 0 and print "$_\n"; $_ == $target and $want = 3; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2020-10-27 19:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (257 votes). Check out past polls.

    Notices?