Yeah, I know that concepts, and I know that an ampersand in a file name may be "dangerous" somehow (even if the shell normally escapes it).
But as long as I can do
Code:
touch 'This file contains an &.pdf'
I'd wish the Perl script to do the same.
I haven't written the Perl script by myself, I'm just modifying it in some parts, by the way the situation is the following:
there is a while loop looping through the parts of an Entity (parsed with MIME::Parser), so there is the following line:
Code:
[...]
$fileName1 = $entity->parts($i)->head->recommended_filename;
[...]
if I print that variable, it prints "You & me.pdf" (and this is right).
Moreover there is this line:
Code:
[...]
$fileName2 = $entity->parts($i)->bodyhandle->path;
[...]
and if I print that second variable, it prints "/
some_path/msg-1267095268-5557-0/You %26 me.pdf" (and here you can see the "%26" instead of the "&"). That absolute path is where the e-mail attachment is saved.
Now, if I try to change the "&" into something else (for example, "and") with:
Code:
$fileName2 = $entity->parts($i)->bodyhandle->path;
$fileName2 =~ s/%26/and/g;
$entity->parts($i)->bodyhandle->path($fileName2);
and print the variable again, now it prints "/
some_path/msg-1267095268-5557-0/You and me.pdf" (and this is OK!), but the real file on the filesystem *is still saved* with the "%26" in its name.
What a crap...