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
|
---|
In Section
Seekers of Perl Wisdom