Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by choroba (Abbot)
on Nov 22, 2012 at 08:51 UTC ( #1005080=note: print w/ replies, xml ) Need Help??


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
Re^2: Is it possible to get all tetra words with correct starting position using a better code within a loop?
by supriyoch_2008 (Scribe) 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,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-07-29 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (222 votes), past polls