sanket vaidya wrote:
Hi all,
Hello,
Kindly look at the code below:
my ($bi, $bn, @bchrs);
$bi starts out at 0.
my $boundry = "";
foreach $bn (48..57,65..90,97..122) {
$bchrs[$bi++] = chr($bn);
$bchrs[ 0 ] is assigned a value and then $bi is incremented to 1.
print "$bchrs[$bi]";
Now print $bchrs[ 1 ] which is undefined.
}
Output:
Use of unitialized value within @bchrs
What you want to do:
my $boundry = '';
my @bchrs;
for my $bn ( 48 .. 57, 65 .. 90, 97 .. 122 ) {
push @bchrs, chr $bn;
print $bchrs[ -1 ];
}
Or perhaps:
my $boundry = '';
my @bchrs = map chr, 48 .. 57, 65 .. 90, 97 .. 122;
print @bchrs;
Or even perhaps:
my $boundry = '';
my @bchrs = ( 0 .. 9, 'A' .. 'Z', 'a' .. 'z' );
print @bchrs;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/