Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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: (12)
As of 2019-02-18 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (100 votes). Check out past polls.

    Notices?