Could someone be so kind as to help me with this? I'm working on modifying a smilies sub routine for a bulletin board, I would like for it to do the conversion to the IMG tag if and only if that image file exists, otherwise leave it untouched. Here is what I tried:

Unless you only have one available smile, this is never going to match because the comparison is the inverse of what it should be ($avl_smilies may contain $2, but $2 won't usually contain $avl_smiles).

Even inverted, the search has problems because 'big' will actually match 'bigsmile', so you'll want to use a pattern instead and anchor it (/\b$pattern\b/).

... won't leave :smile: untouched, but rather change it to smile (sans :'s). You can get around that by either replacing it with ":$2:" and/or by altering your regegp to save the entirety of the original match.

It also won't catch any :smiles: at the start or the end of a string as you embed whitespace in the pattern.

The "Testing testing IMG testing testing SRC=/graphics/.gif" is actually a good trick as it appears perl is treating your everything inside <> as an array and selecting the element corresponding to match number. (ie, $array[$match_no - 1]).

I'll have to play more to see if that's a bug or a feature, but you'll want to escape the entire string for your purposes.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">quote:</font><HR>It seems as if $2 is being modified but I don't know where<HR></BLOCKQUOTE>

See above code for the where. :-)

Everytime you do a match, you reset $1, $2, etc. so while it's available for the search, it's not available anywhere after unless you explicitly save it to $2 again with parenthesis.

is not a syntax error. Well <> is both the readline() operator for files, and the glob() operator for shell file-globs. Perl thinks you're using <IMG SRC...> as a file glob here, and it does something annoying in this case. Try this:

It prints 'what did Perl '. It doesn't print 'do?'. This is because (as far as I've seen) if Perl gets an argument to glob that isn't globbish, it just returns it. 'do?' is globbish, and matches a file that is three characters long and starts with 'do'. But the others just get returned. It's an icky 'feature' that bit you.