in reply to Multiple Input help

Your issue is arising because the first variable Perl is trying to interpolate is read as $userinput1_. You can avoid this issue by wrapping your variable name in curly brackets:

#!/usr/local/bin/perl use strict; use warnings; my ($userinput1, $userinput2); $userinput1 = <STDIN>; #first name $userinput2 = <STDIN>; #last name print "Hello ${userinput1}_$userinput2";

Note I fixed a typo in your variable names. As well, given your intended output, you likely want to chomp your inputs:

#!/usr/local/bin/perl use strict; use warnings; my ($userinput1, $userinput2); chomp($userinput1 = <STDIN>); #first name chomp($userinput2 = <STDIN>); #last name print "Hello ${userinput1}_$userinput2";

Replies are listed 'Best First'.
Re^2: Multiple Input help
by toolic (Bishop) on Feb 04, 2011 at 20:25 UTC