I don't think you've provided quite enough information to get a complete answer. Two aspects of your question seem vague to me:

  1. You provide some samples of "special characters" but end it with "etc..." Knowing exactly what you consider to be "acceptable characters" and what you consider to be "special characters" may change the answer a bit.

  2. You say you want to "strip special characters" without "damaging the file information". I would need to know what the resulting output is going to be used for in order to determine if the information is damaged in the stripping process.

On the second point, it may help to provide both a description of what the information is going to be used for and some examples of what your input and desired output should be.

If deleting the special characters damages the information, you may want to encode them or escape them, but the way to do this is highly context dependent.

Without additional information, all I can offer is to add one line to your sample code:

open(INFILE, "$command |"); print "$command -report\n"; while (<INFILE>) { $files = @f[15]; # Delete special characters like ; ' $ ^ $files =~ tr/;'$^//d print OUTFILE "$SQL_insert ('$files');\n"; ... }

-- Eric Hammond


In reply to Re: Replacing charecters in files by esh
in thread Replacing charecters in files by raj8

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.