in reply to In-place editing of files

What if you stored the $N variable into another one before using s///?

Replies are listed 'Best First'.
Re^2: In-place editing of files
by seuratt (Novice) on Sep 21, 2004 at 15:09 UTC
    my first run at this problem actually landed me with something like that, but it lacked the grace of a good hack. deciding that a concise solution was not to be found with this problem, i chose to try and compensate with legibility.

    here's that awkward first solution of mine using the temp val:

    s/ ( ^Tag \s+ \{ [^\}]* \n \s+ Name \s+ \") (.*?) (\" [^\}]* \} ) /join '', $1, despace($2), $3 /emsgx; print; sub despace { my $x = shift; $x =~ s/ //g; return $x; }