in reply to Array - Reading frame problem

I'm not sure I understand you're question. Do you want to create an array so that each element in the array contains exactly one character, in sequence, from a string? That's pretty simple with split:
my $sequence = "1234567890"; my @chrsequence = split //, $sequence; print "array has " . scalar @chrsequence . " elements: @chrsequence\n" +;
The first argument to split in this case is an empty regex, which happens to have the effect of splitting the input string at every character.

Replies are listed 'Best First'.
Re^2: Array - Reading frame problem
by Nadiah (Novice) on Jul 16, 2005 at 15:33 UTC

    Haha :) thanks graff.. but is it possible to just display the sequence from position 1 onwards and right to the end? (excluding position 0)

      You just need to learn more of the basics of perl syntax. There are lots of ways to do whatever you want with any subset of array elements:
      print "$_\n" for ( @array[1..$#array] ); # which is the same as: for my $i ( 1 .. $#array ) { print "$array[$i]\n"; } # and $" = "\n"; print "@array[1..$#array]\n";
      It is, using the slice notation already mentioned above.
      my $sequence = "1234567890"; my @chrsequence = (split //, $sequence)[1..length($sequence)-1]; print "array has " . scalar @chrsequence . " elements: @chrsequence\n" +;


      holli, /regexed monk/