in reply to Re^3: search and replace with a variable
in thread search and replace with a variable

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";

Replies are listed 'Best First'.
Re^5: search and replace with a variable
by davido (Cardinal) on Apr 09, 2014 at 20:36 UTC

    "Here's the entire code."

    Really? See Re^2: search and replace with a variable. Your "entire code" won't compile because you added use strict; to it before posting, which catches the fact that you misspelled $fqdn on line 27. If it were spelled correctly, the substitution would work as expected. But do read Re^2: search and replace with a variable, because without proper file locking your next bug is only a few web hits away.


    Dave

Re^5: search and replace with a variable
by mtmcc (Hermit) on Apr 09, 2014 at 15:58 UTC
    Have you checked to see whether $q->param('fqdn') and $q->param('address') are successful in getting the strings you want?
      Yes. They both read in just fine. The last lines of the code confirms this with a print out.