Hello,

I'm a new Perl user, developing a Perl script that uses regular expressions 
to resolve environment variables as it parses through a text file. The 
platform is Unix - Korn shell.  I need to escape a number of characters; 
which works fine, except for double backslashes (\\).  I cannot get the 
script to properly escape these.  Here's the code for my script. (I've 
tried using both straight backslashes as well as setting a string of 
backslashes to the $dbs variable - neither with success.) I'd be much 
appreciated of any seasoned veteran who could provide a tip!

open (in_file, $ARGV[0]) || die "Can't open file $ARGV[0]\n";
while (<in_file>) {
        
        $dbs='\\\\';                #testing escape \\ option
        my $in_string = $_;
        $in_string =~ s/\$dbs/\\\$dbs/g;    #escape \\  testing
        $in_string =~ s/\\/\\\\/g;          #escape \
        $in_string =~ s/\//\\\//g;          #escape /
        $in_string =~ s/\*/\\\*/g;          #escape *
        $in_string =~ s/\(/\\\(/g;          #escape (
        $in_string =~ s/\)/\\\)/g;          #escape )
        $in_string =~ s/\&/\\\&/g;          #escape &
        $in_string =~ s/\|/\\\|/g;          #escape |
        $in_string =~ s/\"/\\\"/g;          #escape "
        $in_string =~ s/\'/\\\'/g;          #escape '
        $in_string =~ s/\$AUTO/\\\$AUTO/g;  #escape $AUTO, for output 
files
        print "echoing $in_string\n";       #debug
        my $out_string=`echo $in_string`;
        print $out_string;

        }

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to