in reply to concatenation through substitution?

$line =~ s/$line/$prefix: $line/;
Ooops. You're treating the contents of $line as a regex on the left side of a substitute. Many of those lines have regex-significant characters, so they don't match themselves.

You can do this the hard way:

$line =~ s/\Q$line/$prefix: $line/;
Or the much easier way:
$line =~ s/^/$prefix: /;

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: concatenation through substitution?
by Anonymous Monk on Dec 31, 2004 at 14:57 UTC