Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Editing Listed Data (index, stack)

by Anonymous Monk
on Mar 25, 2013 at 01:03 UTC ( #1025211=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @stuff = 0 .. 9;
    for my $ix ( 0 .. $#stuff ){
      my $item = $stuff[$ix];
      my $prev = $stuff[$ix-1];
      my $next = $stuff[$ix+1];
    }
    
  2. or download this
    my @stuff = 0 .. 9;
    my $lastitem = "";
    for my $item ( @stuff ){
    ...
      }
      $lastitem = $item;
    }
    
  3. or download this
    my @stuff = 0 .. 9;
    my @lastitem ;
    for my $item ( @stuff ){
    ...
      push @lastitem, $item;
      shift @lastitem while 3 == @lastitem; ### keep at most 3 last items
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2018-11-21 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (237 votes). Check out past polls.

    Notices?