First off, I just wanted to say thanks for helping get my little script going. Almost everything is working great!

I am having one little problem though. Some of the names of the users contain symbols, for instance using the square brackets, or !,),{,* and many others. I've found a problem where if a name such as
[ROT] THE MAN
is used to search for, when it searches the line strings, it will assume we are using ROT THE MAN to search with, which is not the case, and ends up not actually finding what we need. I don't know if there is a different type of variable to use, or a different search to use or what, but I'm totally lost as to what to try next. Here's the code thus far...

Oh yeah, see "Simple file editing problems" for the original problem I had.

print "\nEnter extension of files to look in (example: log or tx +t):\n\n"; $fileext = <STDIN>; $fileext = lc($fileext); print "\nConfirmed: $fileext\n\n"; chomp $fileext; print "\nEnter exact name of player to find and replace:\n\n"; $playertofind = <STDIN>; print "\nConfirmed: $playertofind\n\n"; chomp $playertofind; print "\nEnter exact name of player to replace $playertofind with:\n\n +"; $newplayer = <STDIN>; print "\nConfirmed: $newplayer\n\n"; chomp $newplayer; @filestocheck = <*.$fileext>; foreach $file (@filestocheck) { open FILE, "$file" or die "\nError: Unable to open file for read. +.."; @lines = <FILE>; close FILE; open FILE, ">$file" or die "\nError: Unable to open file for writ +e..."; foreach $line (@lines) { $line =~ s/$playertofind/$newplayer/g; print FILE $line; } print "\nFile $file has been corrected.\n"; close FILE; }

To put it simply, I need to search for names that have square brackets or other symbols in them, and as of now, I don't think I can.
Any Ideas?

Thanks for all the help!! I know I still have a lot of work to do, but I'm still trying to get the functional part going first.

I really appreciate it!

Alan

In reply to Simple file editing problems2 by alpal

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.