in reply to Reading special characters from file?

Yup there are loads of ways ;-)1 Although as it's been said there are few situations when you can implicitly use them as values.
1. quotemeta() being the most obvious.

--
Brother Frankus.
  • Comment on Re: Reading special characters from file?

Replies are listed 'Best First'.
Re: Re: Reading special characters from file?
by jbwiv (Acolyte) on Apr 26, 2001 at 17:36 UTC

    quotemeta() did the trick. The problem was occurring because I passed the files to the shell using:

    $cmd = 'someshellexe ' . $basepath . '/' . $file; $rc = qx($cmd);

    The $ was being interpreted when passed to the shell. Changing this to:

    $cmd = 'someshellexe ' . $basepath . '/' . $file; $escapedcmd = quotemeta($cmd); $rc = qx($escapedcmd);
    worked like a charm. Thanks to all for the help!
      A hint: you can do that a bit more readably by using interpolation -- note that Perl won't doubly interpolate, even though the shell might once you pass the value to it:
      $cmd = "someshellexe $basepath/$file"; $cmd = quotemeta($cmd); $rc = qx($cmd); #
      ... unless, as I take it, $rc eq 'result code', in which case use $rc = system($cmd), unless the result code is actually in the output of the command, in which case use qx.