http://www.perlmonks.org?node_id=682583


in reply to First word

Step-by-step:

match a single word character/\w/
match a word /\w+/
match a word at the start /^\w+/
capture it /^(\w+)/
bind the pattern to a string $x =~ /^(\w+)/
assign captured word my ( $word ) = $x =~ /^(\w+)/

The parentheses around $word are important.

Update: Reformatted


Unless I state otherwise, my code all runs with strict and warnings