in reply to Parsing individual words from a file

open INPUT, "foo" or die; my @words = map /\S+/g, <INPUT>;

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

update: Yeah, forgot the "g", sorry.

Replies are listed 'Best First'.
Re^2: Parsing individual words from a file
by Hue-Bond (Priest) on Oct 08, 2006 at 17:48 UTC
    my @w = map /\S+/, <DATA>; use Data::Dumper;print Dumper \@w; __DATA__ aboveboard aboveground abovementioned abrade Abraham Abram Abramson abrasion abrasive abreact abreast abridge abridgment abroad

    Produces:

    $VAR1 = [ 1, 1 ];

    Test your code the next time ;^). You really meant /\S+/g:

    my @w = map /\S+/g, <DATA>; use Data::Dumper;print Dumper \@w; __DATA__ aboveboard aboveground abovementioned abrade Abraham Abram Abramson abrasion abrasive abreact abreast abridge abridgment abroad
    $VAR1 = [ 'aboveboard', 'aboveground', 'abovementioned', [...]

    --
    David Serrano