I think I would do things a little differently.
Owen wrote:
I would like to replace all instances of
@non_space_characters[non_space_characters] with $non_space_characters[non_space_characters] [...] $line=~s/(@)(\S+\[\S+\])/\$$2/g; __DATA__ @[EMAIL PROTECTED]@banana[4];
So this is my solution to your problem. The reason your solution does not work is because \S matches all non-space characters, including your '+' and '=' signs. My solution uses a "zero-width lookahead assertion".
#!/usr/bin/perl use strict; use warnings;
while ( <DATA> ) { s! \@ # match a '@' (?= # start look ahead, which has to match, but # will not be substituted \S+ \[ \S+ \] ) !\$!gx; # replace with '$' print; }
__DATA__ @[EMAIL PROTECTED]@banana[1]; @array[3] = @array[4] + @banana[2]; @[EMAIL PROTECTED]@banana[ 3 ];
To get your solution to work, I would use negated character classes ("anything but '+' or '=' or spaces:
s/\@([^=+\s]+?\[[^=+\s]+?\])/\$$1/g;
Best regards,
Damon --
Damon Allen DAVISON Romanisches Seminar Universität zu Köln
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>