Oops... so the OP just need this ??
I still can't read the logic, but :

# perl
use strict;

my $line="abcdefgh";
print "Outline 1: $line\n";

for my $cut (2 .. length($line))
{ my @round = $line =~ /(?=(.{$cut}))/g;
  print "Outline $cut: @round\n";
}

Can do the same =)

Rgds,
Connie

----- Original Message ----- 
From: "zentara" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 15, 2002 7:35 PM
Subject: Re: writing short code to perform same?


> On Thu, 15 Aug 2002 01:40:16 -0700,      (Shivani)
> wrote:
> 
> >how do i solve this?
> >
> >my $line="abcdefgh";
> >
> >i want output which has 8 lines:
> >1st outline: abcdefgh
> >2nd outline:ab bc cd de ef fg gh
> >3nd outline:abc bcd cde def efg fgh
> >4th outline.......so on
> >
> >please let me know the shortest code tp perform this. i can run it but lot
> >of code..
> 
> Here is a brute-force approach adapted from a cookbook example.
> ########################################################
> #!/usr/bin/perl
> my $line="abcdefgh";
> print "$line\n";
> @yeslap = $line =~ /(?=(\w\w))/g;
> print "@yeslap\n";
> @yeslap = $line =~ /(?=(\w\w\w))/g;
> print "@yeslap\n";
> @yeslap = $line =~ /(?=(\w\w\w\w))/g;
> print "@yeslap\n";
> @yeslap = $line =~ /(?=(\w\w\w\w\w))/g;
> print "@yeslap\n";
> @yeslap = $line =~ /(?=(\w\w\w\w\w\w))/g;
> print "@yeslap\n";
> @yeslap = $line =~ /(?=(\w\w\w\w\w\w\w))/g;
> print "@yeslap\n";
> @yeslap = $line =~ /(?=(\w\w\w\w\w\w\w\w))/g;
> print "@yeslap\n";
> ########################################################
> 
> output:
> 
> abcdefgh
> ab bc cd de ef fg gh
> abc bcd cde def efg fgh
> abcd bcde cdef defg efgh
> abcde bcdef cdefg defgh
> abcdef bcdefg cdefgh
> abcdefg bcdefgh
> abcdefgh
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to