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
In reply to Re: First word
by FunkyMonk
in thread First word
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |