Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: First word

by andreas1234567 (Vicar)
on Apr 24, 2008 at 08:56 UTC ( #682584=note: print w/replies, xml ) Need Help??


in reply to First word

Like this?
$ perl -l use warnings; use strict; my $x = "hey dude what's up"; (my $y = $x) =~ s/(\w+).*/$1/; print $y; __END__ hey
--
No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]

Replies are listed 'Best First'.
Re^2: First word
by Anonymous Monk on Apr 24, 2008 at 09:10 UTC
    Winner winner, chicken dinner! (saw the movie 21 last night, it comes highly recommended). Yes thats perfect! Just so I can make sense of it and use it in future, any chance you could explain s/(\w+).*/$1/ Thanks again, it's perfect.
      You can read all about the Substitution Operator in the free online documentation at perlretut. Search for "Search and replace". There are dazzling multi-color code examples complete with hyperlinks!

      Or, if you prefer reading from a book, Learning Perl is a good place to start.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-01-21 21:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (59 votes). Check out past polls.

    Notices?