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.