G'day slugger415,
The effect you're seeing with the four characters of ".mp3" overwriting the first four characters of "newfile",
generally indicates an embedded carriage return. Such as:
$ perl -e 'my $x = "newfile"; my $y = "\r.mp3"; print "$x$y\n"'
.mp3ile
You haven't shown your whole code, or cut it down to something that reproduces the behaviour (see SSCCE).
I suspect you haven't used the strict and warnings pragmata:
they're certainly not included with the code you posted.
Your $str appears to be a package variable: action-at-a-distance is a possibility.
Interspersing \n and $/ is questionable. Why are you doing this?
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.