Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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 ( [id://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?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 13:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found