in reply to Counting the number of replaces

I noticed that I had an incorrect superstition about using <I>, namely the brackets, in the left side of s///, as I thought it was normally replaced by reading from a filehandle. It seems to work here, though, so I wonder why I believed that....

Replies are listed 'Best First'.
Re^2: Counting the number of replaces
by dsheroh (Monsignor) on Jun 26, 2006 at 15:24 UTC
    Because Perl is rather context-sensitive and uses <I> to mean that in other contexts? In the code:
    while (<I>) { s/<I>/<italic>/g; }
    the first <I> reads from a filehandle and the second is literal text to replace. Fun, isn't it? :)