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 wrote: > >> On Jan 18, 2015, at 9:03 AM, Mike 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 $insul

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

Re: Using regular expressions to populate a variable?

2015-01-18 Thread Jim Gibson
> On Jan 18, 2015, at 9:03 AM, Mike 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 populated wi

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.

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 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 variable. Can anyone po

Re: Using regular expressions with delimitaters

2007-04-12 Thread yaron
Hi The "8.1.8" =~ /[\d $versao \s]/ will always return true because the square parenthesis ([]) matches the string against one of the chars inside. In this case the \d (digit) matches because you have a digit inside. In your code you wrote "8.1.8" =~ /$version/. This takes the $version a treat

Re: Using regular expressions with delimitaters

2007-04-11 Thread Chas Owens
On 4/11/07, Rodrigo Tavares <[EMAIL PROTECTED]> wrote: snip if ( "8.1.8" =~ /$version/) snip You are using the operators incorrectly. It should look like this: if ($version =~ /8\.1\.8/) The form is "variable binding_operator regex". Note that the periods need to be escaped otherwise they w

RE: Using regular expressions with delimitaters

2007-04-11 Thread Moon, John
From: Rodrigo Tavares [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 11, 2007 9:31 AM To: beginners@perl.org Subject: Using regular expressions with delimitaters Hello, I need to use the delimiter " " , (one blank space). I read perdoc, i try to use this : if ( "8.1.8" =~ /[\d $versao \s]/)

Re: Using regular expressions

2004-11-24 Thread Gunnar Hjalmarsson
[ Please do not quote the whole message you are responding to, but only what's needed to give context. Also, please type your reply *below* the part(s) of the message you are commenting on. ] Michael Kraus wrote: John W. Krahn wrote: You should *always* verify that the files were opened correctl

Re: Using regular expressions

2004-11-24 Thread John W. Krahn
Michael S. E. Kraus wrote: G'day... Hello, On Wed, 2004-11-24 at 23:10, FlashMX wrote: To be able to do a grep on a file via a perl script do you have to read the whole file in before performing the search and replace? I've been hearing that reading the whole file in takes up memory and if multipl

Re: Using regular expressions

2004-11-24 Thread John W. Krahn
Michael S. E. Kraus wrote: G'day... Hello, On Wed, 2004-11-24 at 23:00, FlashMX wrote: Could you give an example of using grep on a array to do a replace? grep example: if (grep(/bazza/i, @myarray)) { print "Bazza's home!\n"; } OR my @bazza_list = grep {/bazza/i} @myarray; (Either form is

Re: Using regular expressions

2004-11-24 Thread Michael S. E. Kraus
G'day... On Wed, 2004-11-24 at 23:00, FlashMX wrote: > Could you give an example of using grep on a array to do a replace? grep example: if (grep(/bazza/i, @myarray)) { print "Bazza's home!\n"; } OR my @bazza_list = grep {/bazza/i} @myarray; (Either form is fine) However to do a repl

Re: Using regular expressions

2004-11-24 Thread Michael S. E. Kraus
G'day... On Wed, 2004-11-24 at 23:10, FlashMX wrote: > To be able to do a grep on a file via a perl script do you have to read the > whole file in before performing the search and replace? I've been hearing > that reading the whole file in takes up > memory and if multiple users are running the

Re: Using regular expressions

2004-11-24 Thread FlashMX
To be able to do a grep on a file via a perl script do you have to read the whole file in before performing the search and replace? I've been hearing that reading the whole file in takes up memory and if multiple users are running the script then you better have alot of swap and memory. Is thi

Re: Using regular expressions

2004-11-24 Thread FlashMX
Could you give an example of using grep on a array to do a replace? On Wed, 24 Nov 2004 10:05:39 +0530, Prasanna Kothari wrote: >Hi, >Replace >$output = ~ s/AAA*?BBBt/AAA 111 *?222 BBB/g; >with >my $output =~ s/AAA*?BBBt/AAA 111 *?222 BBB/g; > >You can use "perl -c " which will show you such ty

Re: Using regular expressions

2004-11-23 Thread Prasanna Kothari
Hi, Replace $output = ~ s/AAA*?BBBt/AAA 111 *?222 BBB/g; with my $output =~ s/AAA*?BBBt/AAA 111 *?222 BBB/g; You can use "perl -c " which will show you such type of errors. After opening the output file, it's better to check if the file is opened successfully(as done in the case of INPUT). I thin

re: Using regular expressions

2004-11-23 Thread FlashMX
Hi, The code below opens a file and writes the contents to a temporary file. I need to do a search and replace of certain matches in the files and I thought I might be able to use regular expressions. Being new to perl and now trying expressions has almost put me over the edge. When I run the

Re: using regular expressions to find sequences of items in data

2002-01-06 Thread John W. Krahn
"John W. Krahn" wrote: > > Jon Hans wrote: > > > > #ugly > >if ( defined $frequency{$datalist[$first]} && > > defined $frequency{$datalist[$first+1]} && > > $frequency{$datalist[$first+2]} && > > $frequency{$datalist[$first+3]} && > > $frequency{$datalist[$first+4]} && > > $frequency{$datalis

Re: using regular expressions to find sequences of items in data

2002-01-06 Thread John W. Krahn
Jon Hans wrote: > > #!/usr/bin/perl > ### > > I am trying to find all of the reoccurring sequences > excluding the sub sequences. > > Maybe I am missing the obvious, but having a little > perl exposure and not being an expert perl programmer >