dippa wrote:
basic perl problem which is annoying me, the code is:
---
#!/usr/bin/perl -w
use strict;
my $string;
my $subString;
my @indexes;
print "Enter a string:\n";
chomp($string = );
print "\nEnter substring to search for:\n";
chomp($subString = );
## This while loop does what i'm after
dippa wrote:
>
> Trying to work out why:
> 1. the for loop does not work, want the same logic as the while loop
> 2. for(my $pos = -1; $pos == -1; $pos++) only iterates through once
> 3. for(my $pos = 0; $pos == -1; $pos++) does not enter loop at all
Because in both cases your while condition
basic perl problem which is annoying me, the code is:
---
#!/usr/bin/perl -w
use strict;
my $string;
my $subString;
my @indexes;
print "Enter a string:\n";
chomp($string = );
print "\nEnter substring to search for:\n";
chomp($subString = );
## This while loop does what i'm after
#my $pos = -1;