You probably don't want to strip them, but escape them, because, if you strip them, you do damage the information. Anyway, whatever you do, you should do it by modifying $file before inserting it in that string.
You can escape apostrophes (') and backslashes (\) this way:
$file =~ s/([\\'])/\\$1/g;
If you
do want to strip some characters, like semicolons and quotes, in the most straightforward manner, you can do:
$file =~ tr/";//d;
But likely, you may be wanting a smarter way of processing the data, and use some clever
s/// trick. However, I have no idea on what is a generally acceptable format for all cases.
p.s. Please don't use @f[15], use $f[15] instead. If you ran this script with warnings enabled, you'd get a warning about it. Perhaps it works, but my rule of thumb is that you should only use the "@" syntax only when in list context — it is used in scalar context, here. Perl may disagree and never like array slices (because that's what you used) of just one item, so that's where we disagree. :)
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.