Re: Parsing multi column files

2015-01-18 Thread Brandon McCaig
Mike: On Sun, Jan 18, 2015 at 07:00:05PM -0500, Mike wrote: 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

Re: Parsing multi column files

2015-01-18 Thread Mike
Thanks for quick lesson and pro-tips. I'll be sure to implement some of these. In case you were wondering, I am indeed using strict and warnings. diagnostics, too. Thanks again. On 1/18/15 9:05 PM, Brandon McCaig wrote: Mike: On Sun, Jan 18, 2015 at 07:00:05PM -0500, Mike wrote: So I've

Re: Parsing multi column files

2015-01-18 Thread Shawn H Corey
On Sun, 18 Jan 2015 19:00:05 -0500 Mike ekimduna...@gmail.com wrote: 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

Re: Parsing multi column files

2015-01-18 Thread Brandon McCaig
On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote: You would need an array for each column: my $MAX = 10; my @first = (); my @second = (); my @third = (); sub get_columns { my $file = shift @_; open my $fh, '', $file or die could not open $file: $!\n;

Re: Parsing multi column files

2015-01-18 Thread Mike
Thanks. I'll give this a shot. On 1/18/15 7:44 PM, Brandon McCaig wrote: On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote: You would need an array for each column: my $MAX = 10; my @first = (); my @second = (); my @third = (); sub get_columns { my $file = shift @_;

Re: Parsing multi column files

2015-01-18 Thread Charles DeRykus
On Sun, Jan 18, 2015 at 4:00 PM, Mike ekimduna...@gmail.com wrote: 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

Re: Parsing multi column files

2015-01-18 Thread Brandon McCaig
On Sun, Jan 18, 2015 at 07:24:21PM -0500, Shawn H Corey wrote: my @line = ( @first[rand(@first)], @second[rand(@second)], @third[rand(@third)], ); Sorry to beat on you, Shawn, but I missed this the first time around. Those

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Shawn H Corey
On Sun, 18 Jan 2015 11:49:11 -0500 Mike ekimduna...@gmail.com wrote: Hey everyone, I'm trying to find information on how I can use regular expressions to populate a variable. I want to pull text between one set of characters and another set of characters and use that to populate my

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Jim Gibson
On Jan 18, 2015, at 9:03 AM, Mike ekimduna...@gmail.com wrote: I was able to find match extraction in the perldoc. Here is a snippet of what I have. my $insult = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ ); print $insult\n; But $insult is being populated with: 1 It should be

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Charles DeRykus
On Sun, Jan 18, 2015 at 9:28 AM, Jim Gibson jimsgib...@gmail.com wrote: On Jan 18, 2015, at 9:03 AM, Mike ekimduna...@gmail.com wrote: I was able to find match extraction in the perldoc. Here is a snippet of what I have. my $insult = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ ); print

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Mike
I was able to find match extraction in the perldoc. Here is a snippet of what I have. my $insult = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ ); print $insult\n; But $insult is being populated with: 1 It should be populated with text. Can anyone tell me what I'm doing wrong here? Thanks. On

Using regular expressions to populate a variable?

2015-01-18 Thread Mike
Hey everyone, I'm trying to find information on how I can use regular expressions to populate a variable. I want to pull text between one set of characters and another set of characters and use that to populate my variable. Can anyone point me in the right direction? Thanks. -- To

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Mike
Thanks. This worked. On 1/18/15 12:28 PM, Jim Gibson wrote: On Jan 18, 2015, at 9:03 AM, Mike ekimduna...@gmail.com wrote: I was able to find match extraction in the perldoc. Here is a snippet of what I have. my $insult = ( $mech-text =~ m/Insulter\ (.*)\ Taken/ ); print $insult\n; But

Parsing multi column files

2015-01-18 Thread Mike
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