in reply to Removing a Metacharacter from a filename

Any reason you are using backticks and echo when you could open the file for appending?

open my $OTIS, '>>', $otis_db or die "Can't open $otis_db: $!"; print $OTIS "INSERT into COSBRIDGE\n\tvalues$values\n"; close $OTIS

Because it appears it's your shell that has the problem with the &.

$,=' ';$\=',';$_=[qw,Just another Perl hacker,];print@$_;

Replies are listed 'Best First'.
Re^2: Removing a Metacharacter from a filename
by sputnik (Initiate) on Aug 26, 2009 at 23:10 UTC

    Thanks for the reply bv. Actually, I didn't write the original code. I was assigned a quick fix task for removing the ampersand symbol. I would have thought replacing the symbol with an underline would elimate the false error alert. But, it didn't work as I am still getting the Error Message. It does label the filename as "cos.NEW" as is evident in the log file: *** OTIS data uploaded /usr/edi/cos.NEW Wed Aug 26 16:16:36 EDT 2009 *** 1 row created. I guess I am confused on why the scan and replace did not work.

      Well, if you still need to use the scan-and-replace method, you need to move it up before this line:

      $otis_db="$base_dir/otis_db/cos.$script.$cdate.$pid";

      Since after that, any changes to $script do not affect the $otis_db variable, which is what gets used to create the file.

      $,=' ';$\=',';$_=[qw,Just another Perl hacker,];print@$_;