ouput issues

Discussion in 'Perl' started by slash, Jul 22, 2003.

  1. slash

    slash Guest

    Hi,
    I am new to programming an am running into a simple problem and can
    definitely use some advice or suggestions.
    Following is the output the program below generates:

    quick brown fox
    quick brown fox jumped
    quick brown fox jumped over
    brown fox jumped over lazy
    fox jumped over lazy dog
    jumped over lazy dog tripped
    over lazy dog tripped over
    lazy dog tripped over resting
    dog tripped over resting fox


    use Text::Table;
    undef $/;
    my @words = split /\W+/, <> ;
    my $line_number = 2;
    my $n;
    my $n_cols = 5;
    my $col = { align => 'left'}; # no title, left alignment
    my $tb = Text::Table->new( ( $col) x $n_cols);
    my @stack = ( '' ) x $n_cols;
    foreach $word ( @words ) {
    shift @stack;
    push @stack, $word;
    $tb->add( @stack);
    }
    my @lines = $tb->table( $line_number, $n);
    print @lines;

    =============================
    I want to add two more lines to be processed such that the ouput looks
    like the following:

    quick brown fox
    quick brown fox jumped
    quick brown fox jumped over
    brown fox jumped over lazy
    fox jumped over lazy dog
    jumped over lazy dog tripped
    over lazy dog tripped over
    lazy dog tripped over resting
    dog tripped over resting fox
    tripped over resting fox
    over resting fox

    Is this possible?

    Thanks,
    Slash
    slash, Jul 22, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jp Calderone

    Re: ouput redirection..a newbie question

    Jp Calderone, Dec 15, 2003, in forum: Python
    Replies:
    2
    Views:
    292
    Lonnie Princehouse
    Dec 15, 2003
  2. Replies:
    3
    Views:
    352
  3. redirect ouput

    , Apr 23, 2007, in forum: Python
    Replies:
    1
    Views:
    237
    Gabriel Genellina
    Apr 23, 2007
  4. Replies:
    3
    Views:
    497
    Mike Treseler
    Oct 8, 2008
  5. Jack Wright
    Replies:
    0
    Views:
    93
    Jack Wright
    Jul 13, 2005
Loading...

Share This Page