$line contains a line of text from the file, you can't use that as an index into the array. You need to do something like this:
foreach my $index ( 0 .. $#hosts ) { if ( $hosts[ $index ] =~ /$ARGV[0]/ ) { print $hosts[ $index ]; delete $hosts[ $index ]; } }
In reply to Re: deleting a non-numeric scalar within array
by jwkrahn
in thread deleting a non-numeric scalar within array
by pipeops
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |