"I can't find any tutorials that actually teach you how to do it with a text input!"
Did you look in the
tutorials section of this site? If you had done you would have found
Perl Babysteps 1: Your First Simple Script. When posting here please post error messages, saying things "obviously" don't work is not ideal. Check out
How do I post a question effectively? and the
PerlMonks FAQ if you have not already done so.
It looks to me that you could benefit from reading some documentation (see comments in code below) and some basic
tutorials
#!usr/bin/perl
use strict; # perldoc strict
use warnings; # perldoc warnings
print "type hw to print hello world script!\n:> ";
my $cmd = <STDIN>;
chomp($cmd); # perldoc -f chomp
if ( $cmd eq "hw" ){ # does $cmd contain hw?
print "Hello, world";
}else{
print "sorry I didn't understand the command.";
}
Hope this helps
Update: changed stdin to STDIN thanks to
Corion's keen eye :)
Martin