Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: How do you place words from a sentence into an array?

by pg (Canon)
on Oct 26, 2004 at 16:25 UTC ( #402686=note: print w/replies, xml ) Need Help??


in reply to Re: How do you place words from a sentence into an array?
in thread How do you place words from a sentence into an array?

There is a bug, @words ends up only containing the "words" in the last line ;-) as you are resetting it for each line.

Also there was no need for two splits, just one is good enough, and better use strict ;-)

use Data::Dumper; use strict; use warnings; open FILE, "a.txt"; undef $/; $_ = <FILE>; close(FILE); my @words = split; print Dumper(\@words);

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-05-29 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?