Perl: the Markov chain saw | |
PerlMonks |
Re: Create a hash by spliting stringby Utilitarian (Vicar) |
on Feb 09, 2011 at 14:25 UTC ( [id://887213]=note: print w/replies, xml ) | Need Help?? |
You have the basics of it already. you can split on a regular expression, so a character class that included both colon ":" and semi-colon ";" would split your string into a list of 6 elements.
At this point, knowing that any list with an even number of elements can be assigned to a hash is important because that's how you'd complete the task, simply by assigning the output of the split to %hash
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."
In Section
Seekers of Perl Wisdom
|
|