Home » Perl Basics » 03 - Variables
3
Input from Keyboard
Variables can also take their value from user inputs as the script is running
Variables can also take their value from something you enter as the script is running. Example :
#!/usr/bin/Perl -w # author: #modified by: # date: #Purpose: input from keyboard My $name = <STDIN>; ( NEEDS to be capitalized) print “$name” , “\n”; #ENDThat script will actually pose and wait for input from you before continuing. Of course you will want to make it clearer that an input is needed. Like so :
#!/usr/bin/Perl -w # author: #modified by: # date: #Purpose: input from keyboard print “Please enter your name” , “\n”; My $name = <STDIN>; ( NEEDS to be capitalized) print “$name” , “\n”; #END