in reply to Is it possible to get all tetra words with correct starting position using a better code within a loop?

Use substr:
#!/usr/bin/perl use warnings; use strict; use feature 'say'; my $string = 'ABCDEFGH'; my $length = 4; for my $start (0 .. length($string) - $length) { say substr($string, $start, $length), " -> Starting at position $s +tart."; }
Note that Perl uses 0 for the starting position, not 1. If you really need 1, just output $start + 1.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: Is it possible to get all tetra words with correct starting position using a better code within a loop?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Is it possible to get all tetra words with correct starting position using a better code within a loop?
by supriyoch_2008 (Monk) on Dec 03, 2012 at 06:21 UTC

    choroba

    Thank you very much for your prompt reply. I am sorry for late response as I did not have access to internet for quite a few days due to some technical problem.

    Regards,