Substitution/Regex problem

From: Owen (rcook_at_pcug.org.au)
Date: 04/29/04


Date: Thu, 29 Apr 2004 18:31:04 +1000
To: beginners@perl.org

I would like to replace all instances of

 @non_space_characters[non_space_characters] with
 $non_space_characters[non_space_characters]

The program below gets the first one only. How do I get the others?

TIA

Owen
---------------------------------------------------
#!/usr/bin/perl -w
use strict;

my $line;
while (<DATA>){
$line=$_;
#$line=~s/(@)(\S+)(\[\S+\])/\$$2$3/g;
$line=~s/(@)(\S+\[\S+\])/\$$2/g;

print "$line\n";

}
__DATA__
@array[1]=@array[2]+@banana[4];