Majian wrote:
Thanks all .

Hello,

But I found an another question :

If I  wrote this script like this :
#!/usr/bin/perl

use warnings;
use strict;

while (<DATA>){
@lines = $_;

You are assigning one scalar value to the whole array the array will only ever have one element in it.

You need to append each new scalar value onto the array:

push @lines, $_;

Or you could just assign the whole file in one go:

my @lines = <DATA>;


print "$lines[rand @lines]";
}

__DATA__
uriel
daniel
 joel
samue


It would not display the random element of the array

Why ?
Or if I want to display the random element of the array like this ,what
should  I do ?



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to