Tiago Hori wrote:
Hey Guys,

I am a real beginner so at the risk of being slammed by some, I wanted to
get some input.
I'm a beginner, too. I've worked through this chapter somewhat recently, so my advice shouldn't be too hard to understand :-) Hopefully _I_ don't get slammed!
I was trying to do exercise 5 of the 5th edition of learning perl:

You forgot to include "Chapter 4" but that's ok, it wasn't hard to find based on the context since I had the book right here :-)

I'll snip most of your code to the part that I think may be what's slowing you down.



my @peoplec = @people;

my $lastperson = shift @peoplec;

my $beforelast = shift @peoplec;


I think I see what you did, but you can probably make it easier by taking advantage of how 'print' handles arrays as a whole. An example:

#!/usr/bin/perl -wl
use strict;

my @designations = ( 'red', 'two', 'rogue', 'leader' );
print "my array contains: @designations";

#  displays the following....
#  my array contains: red two rogue leader

Then you shouldn't have to iterate through each item of the array, or 'shift' off items from a duplicated array. The problem didn't include commas in the output, which (for me), signaled that I could probably just 'print' the entire array at once.



ground. I have to say this list is a bit daunting  and does not look like a
beginners list at all. I think it, as Cat Stevens would say, a wild world
out there, but some of us are just trying to get by.

That's my view from outside, really outside.

I hear ya!  Keep trying :-)

Brian


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to