Q:

How do I input an Enter using perl?

I have a perl script that I need to tweak.
The script runs and asks me the manually put in an IP address but I want to hard code in the IP address when it asks me to input it so I need to tell the script to type in the IP and then hit enter to proceed with the script.
Can somebody please tell me how to do this? I'm sure this is probably something extremely basic, but I am not much of a scripter so I'm not sure how to do this.
The script where I need to input the IP and hit enter reads as follows:
print "\nPlease enter the IP address of the node:";
chomp($nodeIP= <STDIN>);

Thanks in advance.

A:

Easiest is to replace 
print "\nPlease enter the IP address of the node:";
chomp($nodeIP= <STDIN>);

with just 
$nodeIp="192.168.2.1";

Well using you address of course, not that of my router.
Starting to write to your own stdin, or emulating keystrokes is hairy.
You do not need the chomp() method as that only serves to remove the Enter from the end of the line.

A:

Are you trying automate one script with another?  If that's the case you might be better off using a tool called expect (Expect: A Tool for Automating Interactions.  I've used it for some odd install scripts.
If what you are trying to do is modify a Perl script to just wait for a user prompt then I'd replace:
print "\nPlease enter the IP address of the node:";
chomp($nodeIP= <STDIN>);

With
$nodeIP = "1.2.3.4";
print "\nThe IP is $nodeIP.  If this is correct press ENTER to continue.\n";
<STDIN>

If waiting for an ENTER key press just read STDIN and throw it away.

