Substitution/Regex problem
From: Owen (rcook_at_pcug.org.au)
Date: 04/29/04
- Next message: Jan Eden: "do problem"
- Previous message: Damon Allen Davison: "Re: Help ME! --> Alas - Backreferences are Lexically scoped"
- Next in thread: Damon Allen Davison: "Re: Substitution/Regex problem"
- Reply: Damon Allen Davison: "Re: Substitution/Regex problem"
- Reply: John W. Krahn: "Re: Substitution/Regex problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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];
- Next message: Jan Eden: "do problem"
- Previous message: Damon Allen Davison: "Re: Help ME! --> Alas - Backreferences are Lexically scoped"
- Next in thread: Damon Allen Davison: "Re: Substitution/Regex problem"
- Reply: Damon Allen Davison: "Re: Substitution/Regex problem"
- Reply: John W. Krahn: "Re: Substitution/Regex problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]