perl newbie: how to extract an unknown word from a string

hi,
im quite new to perl regexp. i have a problem where i want to extract a word from a given string. but the word is unknown, only fact is that it appears as the second word in the string.

Eg.
input string(s) :
char var1 = 'A';
int var2 = 10;
char *ptr;

and what i want to do is to get the variable name (var1, var2, ptr ..etc.) from an above like string.
can we use something like (w+) to match a whole word.

thankx in advance.
wolwy.

An easier way might be to use the split function. The following example shows you how to use the split function to extract words from a string.

#!/usr/local/bin/perl -w

my $str = "The quick brown box";

my @words = split(' ', $str);

foreach my $word (@words) {
    print "$word\n";
}

print "All words: @words\n";
print "Second word: @words[1]\n";

exit 0;

small typo in the above

print "Second word: @words[1]\n";
# should be
print "Second word: $words[1]\n";



thankx very much guys,
it worked, the split function was quite useful.