In the program below the "for loop"  is causing the warning...
"Useless use of private variable in void context at ./uselessUse.pl line 16."


If I comment out the "for loop" like this the warning goes away...
#for($i; $i < $n; $i++)
#{
    push (@some_array, $i);
#}

What does the warning mean and how do I get rid of it?

#!/usr/bin/perl
use strict;
use warnings;

sub get_some_array
{
    my $n = shift; #number of elements
    my $i = 0; #loop counter
    my @some_array;
    
    if(defined($n))
    {
        for($i; $i < $n; $i++)
        {
            push (@some_array, $i);
        }
    }
    return @some_array;
}

my @some_array = get_some_array (8);
my $comma = "";
for my $ele (@some_array)
{
    print $comma . $ele;
    $comma = ", ";
}
print "\n";

--
Ron
This is perl, v5.10.1 (*) built for i686-linux-gnu-thread-multi

Reply via email to