Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Non-destructive array processing

by Juerd (Abbot)
on Jan 20, 2003 at 21:40 UTC ( #228501=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
    my @array = 1..10;
    my $r = sub { \@_ }->(@array);
        print "Chunk: @chunk\n";
    print "Original array is still intact! (@array)\n";
  2. or download this
    my @array = 1..10;
    for (my $i = 0; $i <= $#array; $i += 2) {
        my @chunk = @array[$i, $i + 1];
        print "Chunk: @chunk\n";

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://228501]
Approved by gmax
Front-paged by jarich
[stevenlm87]: Needs help. I am taking an online class for perl and is using Padre. How can I get a list from the input in this code? print "What are your favorite hobbies? "; my $hobbies = <STDIN>; chomp $hobbies; print "Your favorite hobbies are '$hobbies'\n";

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2017-02-23 19:52 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (351 votes). Check out past polls.