S
slash
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
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