#!/usr/bin/perl
use strict;
use warnings;
for( $_ = "fred"; s/(.)//; )
{
print "I saw the character [$&]\n";
redo if $& eq 'e';
}
####
I saw the character [f]
I saw the character [r]
I saw the character [e]
Use of uninitialized value in concatenation (.) or string at test line 7.
I saw the character []
Use of uninitialized value in string eq at test line 8.
I saw the character [d]
####
#!/usr/bin/perl
use strict;
use warnings;
for( my $i = 1; $i =~ m/\d/; $i++)
{
print "I saw [$i]\n";
redo if $& == 5;
last if $i == 10;
}
####
I saw [1]
I saw [2]
I saw [3]
I saw [4]
I saw [5]
I saw [5]
Use of uninitialized value in numeric eq (==) at test2 line 8.
I saw [6]
I saw [7]
I saw [8]
I saw [9]
I saw [10]
####
#!/usr/bin/perl
use strict;
use warnings;
for( my $i = 1; $i =~ m/\d/, my $j = $i**2; $i++)
{
print "I saw [$i] and [$j]\n";
redo if $& == 5;
last if $i == 10;
}
####
I saw [1] and [1]
I saw [2] and [4]
I saw [3] and [9]
I saw [4] and [16]
I saw [5] and [25]
Use of uninitialized value in concatenation (.) or string at test2 line 7.
I saw [5] and []
Use of uninitialized value in numeric eq (==) at test2 line 8.I saw [6] and [36]
I saw [7] and [49]
I saw [8] and [64]
I saw [9] and [81]
I saw [10] and [100]
####
#!/usr/bin/perl
use strict;
use warnings;
$_ = 123;
while( m/\d/g )
{
print "I saw [$&]\n";
redo if $& == 1;
last;
}
####
I saw [1]
Use of uninitialized value in concatenation (.) or string at test3 line 9.
I saw []