vonster
asked on
printing contents of an array
i'm trying to print the contents of an array but i keep getting errors:
here is my code:
#!/usr/bin/perl
use strict;
use warnings;
my(@x,@y,@z);
while(<>)
{
next unless /^ATOM/;
my @flds = split;
push @x, $flds[6];
push @y, $flds[7];
push @z,$flds[8];
}
for($i = 0; $i< @x;++$i)
{
print $x[$i]"\n";
}
the error i'm getting is:
Global syhsmbol "$i" requires explcit package name
what do i need to do to solve this?
here is my code:
#!/usr/bin/perl
use strict;
use warnings;
my(@x,@y,@z);
while(<>)
{
next unless /^ATOM/;
my @flds = split;
push @x, $flds[6];
push @y, $flds[7];
push @z,$flds[8];
}
for($i = 0; $i< @x;++$i)
{
print $x[$i]"\n";
}
the error i'm getting is:
Global syhsmbol "$i" requires explcit package name
what do i need to do to solve this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.