Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Array - Reading frame problem

by GrandFather (Saint)
on Jul 16, 2005 at 13:24 UTC ( [id://475444]=note: print w/replies, xml ) Need Help??


in reply to Array - Reading frame problem

Do you mean that you want the string to do this:

0123456789 123456789 23456789 3456789 456789 56789 6789 789 89 9
use strict; use warnings; my $sequence = "0123456789"; my @frames; while ($sequence) { push @frames, $sequence; $sequence = substr $sequence, 1; } print join "\n", @frames;

Perl is Huffman encoded by design.

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

    yes.. kind of.. but i was wondering if it is possible to have "individual" codes which can be reused to find $frame2 and $frame3 respectively (but there's only a need to change variable names).. and not in not in a while loop? it's because i only need to obtain another two more reading frames.


    eg.
    $sequence = "1234567890";
    $sequence .= $frame1;
    $frame 2 = "234567890";
    $frame 3 = "34567890";

      Why are you now using strings in your example, I though the whole point was you wanted to do this on an array (although there is a perf hit, split/join can let you switch back and forth....). String operations are going to be a lot faster here than array operations if you doing this alot with long sequences...

      Isn't this just what you want?

      my @frame1 = @sequence; my @frame2 = @sequence; my @frame3 = @sequence; shift @frame2; shift @frame3; shift @frame3;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://475444]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found