in reply to Basic Perl Regular Expressions

This is just the sort of thing Perl is great at. Here's a bit to get you started.
#!/usr/bin/perl -w use strict; my $sentence = 'A sentence is just a bunch of words'; # Do the magic. my @words = split /\s/, $sentence; # That was it! Now show the results. foreach my $word (@words) { print "$word\n"; }
And don't be shy about reading the docs that come with Perl. They are really quite good. The key one in this case (and for many beginner questions) is called 'perlfunc'.

Also, check out the Tutorials on this site. Very nice. There is one on Split and join.

Replies are listed 'Best First'.
Re: Re: Basic Perl Regular Expressions
by monkfish (Pilgrim) on Nov 12, 2001 at 09:03 UTC
    You might want to split on /\s+/ to be more robust. This will match white space of more than one character.

    You could also split on /\b/ and then grep for word characters if you wanted a slightly different definition of a word. This would split words with hyphons and apostorphes which might or might not be what you want.

    @words = grep (/\w/, split (/\b/, $foo));

    -monkfish (The Fishy Monk)