I wish to be able to access each element individually and thought that using 'join' followed by 'split' would allow me to do this;
Erm, I think you need to read perldata, which should inform you about how arrays work in perl.

What you're doing with your code is joining an array on an empty string, which will create one string comprised of the elements of the array joined together. Then you're splitting on any whitespace1 in that string, which won't work since your array won't contain any whitespace, then split returns the original string which is then assigned to $uniques_slopes[0].

As you can guess, this does not do what you want at all. To access individual array elements, you just access them using the square bracket syntax like so

## see. perlop for more info on qw// my @array = qw/ one two three four five /; ## create a range from 0 to the index of the last element in @array for my $i (0 .. $#array) { ## acccessing element at $i using square bracket syntax print $array[$i]; } ## this is a more idiomatic approach print for @array;
Thanks for the info, it has made helping much easier, and if you plan on sticking around then I recommend joining up :)
HTH

_________
broquaint

1 see. the split docs on why you can just a ' ' as the delimiter for this special case


In reply to Re: Re: Re: Re: Re: going loopy by broquaint
in thread going loopy by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.