$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:
Or the much easier way:$line =~ s/\Q$line/$prefix: $line/;
$line =~ s/^/$prefix: /;
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to •Re: concatenation through substitution?
by merlyn
in thread concatenation through substitution?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |