Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: How to read from a file instead from a hard coding list.

by lidden (Curate)
on Apr 25, 2012 at 04:10 UTC ( #966980=note: print w/replies, xml ) Need Help??


in reply to How to read from a file instead from a hard coding list.

If I undestand correctly you should change:

my @words=qw( portion answers printer program );

To:

my $file = '/path/to/file'; my @words; open my $fh, '<', $file or die "Could not open $file: $!"; while(<$fh>){ push @words, split; } close $fh or die $!;

Untested.

Replies are listed 'Best First'.
Re^2: How to read from a file instead from a hard coding list.
by 300zxmuro (Initiate) on Apr 26, 2012 at 02:54 UTC

    Thank you ALL, I really appreciate your time and ideas. It is possible to help me with the piece that counts the number of attempts the gamer used and posted at then end? THANKS AGAIN!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://966980]
help
Chatterbox?
[vedagiri89]: hi all! i need your help

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2018-06-19 11:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?