Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: search and replace with a variable

by mtmcc (Hermit)
on Apr 09, 2014 at 15:20 UTC ( [id://1081668]=note: print w/replies, xml ) Need Help??


in reply to search and replace with a variable

What is the content of @lines? My guess is the problem lies there. You shouldn't need the /e modifier.

This works, for example:

#!/usr/bin/perl use warnings; use strict; my $fqdn = 'first'; my $address = 'second'; my @lines = ('RECORDNAME', 'RECORDIP', 'third'); print STDERR "BEFORE: @lines\n"; foreach(@lines) { $_ =~ s/RECORDNAME/$fqdn/; $_ =~ s/RECORDIP/$address/; } print STDERR "AFTER: @lines\n";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1081668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-25 14:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found