I am trying to write a Perl program that reads in lines from a text file, and, for each line, extract the first \"word\" from the line, and perform a different action based
This will cover all of your cases and then some:
my ($key, $value) = split /\s*:\s*/, $inputline, 2;
(Or, in English, split $inputline into a maximum of two elements separated by any amount of whitespace, a colon and any amount of whitespace.)
$inputline