Re: Example Input Datas

[email protected] (Jeff Pang)
Newsgroups perl.beginners.cgi
Message-ID <31548806.1173373169881.JavaMail.root@elwamui-cypress.atl.sa.earthlink.net>
>
>Hi Jeff,
>
>This IP 192.168.1.1 will replaced by IP defined from user.
>
>example:
>
>Enter with IP : 10.0.0.1
>Submit
>
>When somebody  to type one value, it will replaced the file value.
>
>IP: 192.168.1.1 -> will be replaced -> 10.0.0.1
>

Got it.Then your script is may right.
The only note is the meta-characters.becase '.' is a meta-character in Perl,so given this case:

$source_ip = '192.168.1.1';
$dest_ip = '10.0.0.1';
s/$source_ip/$dest_ip/g;

maybe meet some problems.
The better way is use \Q for disable quote meta-characters.like:

s/\Q$source_ip/$dest_ip/g;

From perldoc perlre:

           \E          end case modification (think vi)
           \Q          quote (disable) pattern metacharacters till \E

Hope this useful.

--
http://home.arcor.de/jeffpang/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.