So I've got a text file in a multi column format (three columns), each column is separated by a single space. Here is a snippet for reference:

artless base-court apple-john
bawdy bat-fowling baggage
beslubbering beef-witted barnacle

I want to be able to randomly select a word from the first column, then from the second column, then from the third column, and concatenate them to together into a single string. Here's the code I currently have, but I'm stuck:

sub gen_ins {
open(FH, '<', 'insults2.txt') or die "[-] ERROR: Can't find insult list.";
    my @cols = split (" ", <FH>);
    print "$cols[0]";
    close FH;
}

gen_ins();

When currently run, gen_ins() will print out the first word of the given column: $cols[0], $cols[1], or $cols[2]. How can I access the rest of the words below the first?

Thanks.

--
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