blahblahblah has asked for the wisdom of the Perl Monks concerning the following question:

I have the same cgi file upload script on a unix machine and an NT machine. Everything works fine on unix. But on the NT, CGI.pm seems to be turning apostrophes into :: in the filename. For example,
Joe's test file
into
Joe::s test file
This comes from the following code:
$req = new CGI; $file = $req->param("FILE1");
And the form looks like this:
<form method=\"POST\" action=\"/cgi/upload.pl\" ENCTYPE=\"multipart/fo +rm-data\"> ... <input type=\"file\" name=\"FILE1\"> ...

This is a problem because NT doesn't like colons in filenames. I'm about to start poking around in CGI.pm, but I figured I'd ask first to see if anyone has seen this before and figured it out.

Replies are listed 'Best First'.
Re: CGI.pm turns apostrophes into :: in filenames?
by Juerd (Abbot) on Jan 04, 2002 at 20:27 UTC
    Are you sure you're not using some sort of bareword or interpolation?

    From perlmod:

    The old package delimiter was a single quote, but double colon is now the preferred delimiter, in part because it's more readable to humans, and in part because it's more readable to emacs macros. It also makes C++ programmers feel like they know what's going on--as opposed to using the single quote as separator, which was there to make Ada programmers feel like they knew what's going on. Because the old-fashioned syntax is still supported for backwards compatibility, if you try to use a string like "This is $owner's house", you'll be accessing $owner::s; that is, the $s variable in package "owner", which is probably not what you meant. Use braces to disambiguate, as in "This is ${owner}'s house".

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Re: CGI.pm turns apostrophes into :: in filenames?
by blahblahblah (Priest) on Jan 04, 2002 at 22:08 UTC
    Forget about this, I just downloaded the latest version of CGI.pm and it works correctly now.

      Regardless, it may have had something to do with the fact that early Perls used the single apostrophe ("'") to separate the package name from a variable name. In other words, $package'var used to mean the same as $package::var does today. It actually still works, but it is deprecated.

      dmm