Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: First word

by FunkyMonk (Chancellor)
on Apr 24, 2008 at 08:56 UTC ( [id://682583]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://682583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-04-19 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found