in reply to search and replace with a variable

Since you do not have any perl code in the substitution, why are you using the /e modifier?

It should work fine without the /ee.

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992

Replies are listed 'Best First'.
Re^2: search and replace with a variable
by tronmason (Initiate) on Apr 09, 2014 at 15:39 UTC
    ...but it doesn't. The replacements just end up being blanks. Do note that it works just fine when I declare those variable as direct strings i.e.

    my $fqdn = 'XXXX_NAME_vpn'; my $address = '143.55.67.89';
      Well, that makes it pretty clear: your problem is in the code you didn't show us; the part by which you obtain and generate the scalars! (possibly need to chomp?)

      check Ln42


      Questions containing the words "doesn't work" (or their moral equivalent) will usually get a downvote from me unless accompanied by:
      1. code
      2. verbatim error and/or warning messages
      3. a coherent explanation of what "doesn't work actually means.
        Here's the entire code. Those values are being read in via CGI. I tried chomp already. See below:
        #!/usr/bin/perl use strict; use CGI; use Getopt::Long; use FindBin qw($Bin $Script); my ($BASE,$NAME)=($Bin,$Script) ; my ( $fqdn, $address ); my ( @results, $result, $response ); my $sestimeout = 3600; open(FILE, "<ADDACS.csv") || die "File not found"; my @lines = <FILE>; close(FILE); my $q = CGI->new; my $fqdn = $q->param('fqdn'); chomp $fqdn; my $address = $q->param('address'); chomp $address; my @newlines; foreach(@lines) { $_ =~ s/RECORDNAME/$fqdn1/; $_ =~ s/RECORDIP/$address/; push(@newlines,$_); } open(FILE, ">ADDACS1.csv") || die "File not found"; #print "Content-type: text/plain\n\n"; print FILE @newlines; close(FILE); print "Content-type: text/plain\n\n"; print "$address / $fqdn";