Re: grep - block with start & end text

2016-03-20 Thread Neil Bowers
Hi Prashant, > Can you please help me to grep below 'block of text' from my file ? this > blocks occurs number of time & I want to grep all in between lines of this > block - There are several ways you can do this. Let’s say that “begin” is the start of a block, and “end” is the end. So here’s

Re: grep - block with start & end text

2016-03-19 Thread Andrew Solomon
And to understand Scott's easy to write, hard to understand approach: http://blog.geekuni.com/2016/03/perl-flip-flop.html Andrew On Fri, Mar 18, 2016 at 3:50 PM, Scott Hall wrote: > > > On Fri, Mar 18, 2016 at 9:40 AM Prashant Thorat > wrote: > >> Hi All, >> >> Can you please help me to grep

Re: grep - block with start & end text

2016-03-19 Thread Shawn H Corey
On Fri, 18 Mar 2016 19:07:10 +0530 Prashant Thorat wrote: > Can you please help me to grep below 'block of text' from my file ? > this blocks occurs number of time & I want to grep all in between > lines of this block - > > first line is having - retr_test asm1 > & 4th line is having only - END

Re: grep - block with start & end text

2016-03-19 Thread Scott Hall
Thanks Andrew. Your article explained what I did not have the words for. It was very well written. Scott On Fri, Mar 18, 2016 at 1:23 PM Andrew Solomon wrote: > And to understand Scott's easy to write, hard to understand approach: > > http://blog.geekuni.com/2016/03/perl-flip-flop.html > > An

Re: grep - block with start & end text

2016-03-18 Thread Prashant Thorat
Hi All...Thanks a lot for help..!!! On Sat, Mar 19, 2016 at 1:22 AM, Scott Hall wrote: > Thanks Andrew. > > Your article explained what I did not have the words for. It was very > well written. > > Scott > > On Fri, Mar 18, 2016 at 1:23 PM Andrew Solomon wrote: > >> And to understand Scott's

Re: grep - block with start & end text

2016-03-18 Thread Scott Hall
On Fri, Mar 18, 2016 at 9:40 AM Prashant Thorat wrote: > Hi All, > > Can you please help me to grep below 'block of text' from my file ? this > blocks occurs number of time & I want to grep all in between lines of this > block - > > first line is having - retr_test asm1 > & 4th line is having onl

Re: grep array of arrays

2012-08-24 Thread Brandon McCaig
On Thu, Aug 23, 2012 at 05:19:34PM -0400, Shawn H Corey wrote: > You're trying to do too much in one statement. > > for my $coord ( @coords ){ > if( $coords->[0] >= 0 ){ > print join( q{, }, @{ $coords } ), "\n"; > } > } Looks like you're trying to do too much too. ;) You are test

Re: grep array of arrays

2012-08-23 Thread Shawn H Corey
On Thu, 23 Aug 2012 14:17:26 -0700 Jim Gibson wrote: > You could also combine print, grep, and map to accomplish the same > thing. Please don't. If you're having this much trouble getting it right, the person stuck with maintaining it will also have trouble understanding what you coded. Break it

Re: grep array of arrays

2012-08-23 Thread Shawn H Corey
On Thu, 23 Aug 2012 15:58:43 -0500 Chris Stinemetz wrote: > print grep { $_->[0] >= 0 } @coords; You're trying to do too much in one statement. for my $coord ( @coords ){ if( $coords->[0] >= 0 ){ print join( q{, }, @{ $coords } ), "\n"; } } -- Just my 0.0002 million dolla

Re: grep array of arrays

2012-08-23 Thread Jim Gibson
On Aug 23, 2012, at 1:58 PM, Chris Stinemetz wrote: >> >> >> If @coords is just an Array of Arrays then that should be: >> >> print grep { $_->[0] >= 0 } @coords; >> >> >> Your example thinks @coords is an Array of Arrays of Arrays. >> >> >> John >> -- >> > > print grep { $_->[0] >= 0 }

Re: grep array of arrays

2012-08-23 Thread Chris Stinemetz
> > > If @coords is just an Array of Arrays then that should be: > > print grep { $_->[0] >= 0 } @coords; > > > Your example thinks @coords is an Array of Arrays of Arrays. > > > John > -- > print grep { $_->[0] >= 0 } @coords; Just prints the memory adress: ARRAY(0x29d459c)ARRAY(0x29d462c)ARRAY(

Re: grep array of arrays

2012-08-23 Thread Jim Gibson
On Aug 23, 2012, at 12:57 PM, Chris Stinemetz wrote: > Hello List, > I'm trying to grep an array of arrays, but I am getting the following error: > > Can't use string ("1") as an ARRAY ref while "strict refs" in use at > form.pl line 121, <$COORDS> line 1281. > Press any key to continue . . . >

Re: grep array of arrays

2012-08-23 Thread John W. Krahn
Chris Stinemetz wrote: Hello List, Hello, I'm trying to grep an array of arrays, but I am getting the following error: Can't use string ("1") as an ARRAY ref while "strict refs" in use at form.pl line 121,<$COORDS> line 1281. Press any key to continue . . . Below is the grep statement:

Re: grep question

2011-07-19 Thread Dr.Ruud
On 2011-07-19 21:23, Steven Surgnier wrote: I desire a concise conditional statement which simply checks if each entry in an array matches a given string. For example: print "all the same" if (grep {m/test_name/} @bins) == scalar @bins); Your match is not anchored, so ITYM: my $s = $bins[

Re: grep question

2011-07-19 Thread John W. Krahn
Steven Surgnier wrote: Hi, I desire a concise conditional statement which simply checks if each entry in an array matches a given string. For example: print "all the same" if (grep {m/test_name/} @bins) == scalar @bins); #END CODE I thought, "grep will return the number of matches, so why no

RE: grep question

2011-07-19 Thread Ken Slater
> -Original Message- > From: Steven Surgnier [mailto:ssurgn...@gmail.com] > Sent: Tuesday, July 19, 2011 3:24 PM > To: beginners@perl.org > Subject: grep question > > Hi, > > I desire a concise conditional statement which simply checks if each > entry > in an array matches a given string.

Re: grep question

2011-07-19 Thread Brian Fraser
On Tue, Jul 19, 2011 at 4:23 PM, Steven Surgnier wrote: > Hi, > > I desire a concise conditional statement which simply checks if each entry > in an array matches a given string. For example: > > print "all the same" if (grep {m/test_name/} @bins) == scalar @bins); > > #END CODE > > I thought, "g

Re: grep question

2011-07-19 Thread Tessio Fechine
Hello, you can use print "all the same" unless (grep {! /test_name/} @bin); 2011/7/19 Steven Surgnier > Hi, > > I desire a concise conditional statement which simply checks if each entry > in an array matches a given string. For example: > > print "all the same" if (grep {m/test_name/} @bins)

Re: grep and regex

2010-05-25 Thread Akhthar Parvez K
On Sunday 23 May 2010, Rob Dixon wrote: > I think you may have simplified the problem you are facing a little too > much, but the code below does what you ask for. If, as I suspect, this > solution is not applicable to your real data, then please try to > describe the problem rather than coding

Re: grep and regex

2010-05-22 Thread Rob Dixon
On 22/05/2010 15:22, Akhthar Parvez K wrote: On Saturday 22 May 2010, Jim Gibson wrote: On 5/21/10 Fri May 21, 2010 12:13 PM, "Akhthar Parvez K" scribbled: Jim, thanks for your continued help. Jim, forget everything that I "scribbled" upto now, how would you tell Perl to pick 'cd' of 'abc

Re: grep and regex

2010-05-22 Thread Dr.Ruud
Akhthar Parvez K wrote: Jim, Why do you call us Jim? [...] how would you tell Perl to pick 'cd' of 'abcd' and 'abcd' itself and 'pq' of 'pqrs' and 'pqrs' itself, and nothing else, from an array ( = 'abcdpqrsxyz') by a single statement. Why an array? Don't you mean a string? my $s = 'a

Re: grep and regex

2010-05-22 Thread Akhthar Parvez K
On Saturday 22 May 2010, Jim Gibson wrote: > On 5/21/10 Fri May 21, 2010 12:13 PM, "Akhthar Parvez K" > scribbled: > > Shouldn't > > Perl be smart enough to understand that the outer most pair of paranthesis > > and > > | symbol were solely used for alternation (since there're nothing within

Re: grep and regex

2010-05-21 Thread Jim Gibson
On 5/21/10 Fri May 21, 2010 12:13 PM, "Akhthar Parvez K" scribbled: > On Friday 21 May 2010, Jim Gibson wrote: >> You are getting undefs because you >> have alternation (|) between two >> sub-patterns and capturing parentheses in >> each sub-pattern. You also have >> nested parentheses, with

Re: grep and regex

2010-05-21 Thread Akhthar Parvez K
On Friday 21 May 2010, Jim Gibson wrote: > You are getting undefs because you have alternation (|) between two > sub-patterns and capturing parentheses in each sub-pattern. You also have > nested parentheses, with a capturing parenthese pair around the whole. > > Your regular expression is this: >

Re: grep and regex

2010-05-21 Thread Jim Gibson
On 5/21/10 Fri May 21, 2010 8:42 AM, "Akhthar Parvez K" scribbled: > On Friday 21 May 2010, Akhthar Parvez K wrote: > I am stuck with regex again, this time I really need to *fix* it: > > Code: > > my @data = ( 'Twinkle twinkle little star > How I wonder what you are > Up above the world so

Re: grep and regex

2010-05-21 Thread Akhthar Parvez K
On Friday 21 May 2010, Akhthar Parvez K wrote: > Look at this code: > > my @data = ( 'Twinkle twinkle little star > How I wonder what you are > Up above the world so high > Like a diamond in the sky. > 123 > Twinkle twinkle little star > How I wonder what you are'); > my $rx1 = qr{ world.*diamond

Re: grep and regex

2010-05-20 Thread Akhthar Parvez K
On Thursday 20 May 2010, Shawn H Corey wrote: > #!/usr/bin/perl > > use strict; > use warnings; > > use Data::Dumper; > > # Make Data::Dumper pretty > $Data::Dumper::Sortkeys = 1; > $Data::Dumper::Indent = 1; > > # Set maximum depth for Data::Dumper, zero means unlimited > local $Data::Dumpe

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 03:52 PM, Uri Guttman wrote: i didn't say it was for output but for debugging. and i didn't say YOU shouldn't do it. i wrote for others to learn when to and not to use Dumper. it isn't always the best choice. you can use it all the time. they don't need to. simpler print/map is fine f

Re: grep and regex

2010-05-20 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 10-05-20 03:17 PM, Uri Guttman wrote: >>> "SHC" == Shawn H Corey writes: >> SHC> On 10-05-20 02:07 PM, Uri Guttman wrote: >> >> not a major point, but why do you use dumper just to print a list of >> >> tokens? i use dumper for deep

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 03:17 PM, Uri Guttman wrote: "SHC" == Shawn H Corey writes: SHC> On 10-05-20 02:07 PM, Uri Guttman wrote: >> not a major point, but why do you use dumper just to print a list of >> tokens? i use dumper for deeper stuff where i can't just print the data >> easily wit

Re: grep and regex

2010-05-20 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> On 10-05-20 02:07 PM, Uri Guttman wrote: >> not a major point, but why do you use dumper just to print a list of >> tokens? i use dumper for deeper stuff where i can't just print the data >> easily without some code. even single level hashes i wil

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 02:07 PM, Uri Guttman wrote: not a major point, but why do you use dumper just to print a list of tokens? i use dumper for deeper stuff where i can't just print the data easily without some code. even single level hashes i will print directly as i can format it my way and not dumper's

Re: grep and regex

2010-05-20 Thread Uri Guttman
> "SHC" == Shawn H Corey writes: SHC> my @data = qw( The quick brown fox jumped over the lazy dogs. ); SHC> my $regx = qr{ [aeiou] }msx; SHC> my @matches = map { /($regx)/ } @data; SHC> print '@matches : ', Dumper \...@matches; not a major point, but why do you use dumper just to pri

Re: grep and regex

2010-05-20 Thread Shawn H Corey
On 10-05-20 12:52 PM, Akhthar Parvez K wrote: Hi all, Can Perl regex match a string in a list (like Perl grep)? eg:- #won't work $_ = @data; my @matches = /($regx)/g; #works, but not as quite really wanted since it would show the line contains the string, not just the matched string: my @matche

Re: grep Net::FTP

2009-05-27 Thread Mihir Kamdar
thanks John...my problem is solvedam trying to add more functionalities to the script. Will seek help again if faced with any issue.. On Tue, May 26, 2009 at 11:31 AM, John W. Krahn wrote: > Mihir Kamdar wrote: > >> Hi, >> >> I want to write a perl script which will get files from multiple >

Re: grep Net::FTP

2009-05-26 Thread John W. Krahn
Mihir Kamdar wrote: Hi, I want to write a perl script which will get files from multiple directories in remote location using FTP. Following is the script that I tried:- #!/usr/bin/perl use Net::FTP; use strict; for (my $count=0; $count < 2; $count++) { print "Please enter the directory name to

Re: grep and substring then uc

2009-01-09 Thread Mr. Shawn H. Corey
On Thu, 2009-01-08 at 18:23 -0800, Erik Witkop wrote: > Here is what I am trying to do, > > I want to grep on a semicolon, and then upper case the next character. > > So if my input data is in the format of > > Witkop; erik > > I want to find the semicolon and then uppercase the 'e' in erik. >

Re: Grep question

2008-06-05 Thread Dr.Ruud
David Gilden schreef: > my $Comments = param('(Comments'); There is an extra '(' in there that you might not want. Do you use Capitalization to show that the variable is initialised with the value of a parameter? Consider $p_comments or $param_comments or $param{Comments}. -- Affijn, Ruud "Ge

Re: Grep question

2008-06-05 Thread John W. Krahn
Steve Bertrand wrote: David Gilden wrote: Could someone please help me the syntax here my $Comments = param('(Comments'); &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); This should go to &BADemail if $Comments contains either string, regardless else is contained i

Re: Grep question

2008-06-05 Thread Steve Bertrand
David Gilden wrote: Could someone please help me the syntax here my $Comments = param('(Comments'); &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); This should go to &BADemail if $Comments contains either string, regardless else is contained in the $Comments. In a

Re: Grep question

2008-06-05 Thread Rob Dixon
David Gilden wrote: > > my $Comments = param('(Comments'); > &BADemail if ($Comments =~ /[virtualthirst.com|napavalleycf.org]/ig); > > This should go to &BADemail if $Comments contains either string, regardless > else is contained in the $Comments. The answer to your question is BADemail()

Re: grep usage

2008-03-26 Thread John W. Krahn
Johnson, Reginald (GTI) wrote: I am trying to grep an array return the lines that match. From my reading I see that grep returns the number of times an expression was true not the actual expression. My question is how would I get the actual expression. I tested my code with a small input file o

Re: grep usage

2008-03-26 Thread yitzle
Have you tried it? Grep does return the result lines when used in a list context, ie how you used it > @inmhs = grep(/$line/,@mhsArray); print "$_\n" for (@inmhs); >From Perldoc: "Evaluates the BLOCK or EXPR for each element of LIST (locally setting $_ to each element) and returns the list value

Re: grep from one file and write to another

2007-06-24 Thread Vahid Moghaddasi
On 6/24/07, Tom Phoenix <[EMAIL PROTECTED]> wrote: On 6/23/07, Vahid Moghaddasi <[EMAIL PROTECTED]> wrote: But maybe you need the actual password file. You got it, I have to read /etc/passwd file only. > I am not sure how much I can read into memory space without affecting > other programs

Re: grep from one file and write to another

2007-06-23 Thread John W. Krahn
Vahid Moghaddasi wrote: Hi all, Hello, I am trying to read a colon delimited text file (filter.in) then search for each field in another file (/etc/passwd) and if it is found then write that line in the third file (passwd.out). Here is what I have written so far but it is not given me the cor

Re: grep from one file and write to another

2007-06-23 Thread Tom Phoenix
On 6/23/07, Vahid Moghaddasi <[EMAIL PROTECTED]> wrote: For each field (user) in the filter.in file, I will have to find the user in passwd file, wouldn't I need to re-read the passwd file as much as there are fields in filter.in file? Probably not. For one solution, you might be able to use g

Re: grep from one file and write to another

2007-06-23 Thread Vahid Moghaddasi
On 6/23/07, Tom Phoenix <[EMAIL PROTECTED]> wrote: > use File::Copy; Are you actually using File::Copy? I didn't find any call to it in your posted code. Sorry, I left it in by mistake. This code is a small part of a very large program. > use strict; > use warnings; That's good > $|=1

Re: grep from one file and write to another

2007-06-23 Thread Tom Phoenix
On 6/23/07, Vahid Moghaddasi <[EMAIL PROTECTED]> wrote: I am trying to read a colon delimited text file (filter.in) then search for each field in another file (/etc/passwd) and if it is found then write that line in the third file (passwd.out). use File::Copy; Are you actually using File::C

Re: grep is too slow...

2007-01-14 Thread John W. Krahn
Jim Magnuson wrote: > Hi, Hello, > I was able to get my Finnish corpus project off the ground this > week with help from this group; thank you very much. > > Now I've run into a small problem. After reading in the corpus of > 470,000 words and breaking them into syllables, I have created a lis

Re: grep is too slow...

2007-01-14 Thread Jay Savage
On 1/14/07, Jim Magnuson <[EMAIL PROTECTED]> wrote: Hi, I was able to get my Finnish corpus project off the ground this week with help from this group; thank you very much. Now I've run into a small problem. After reading in the corpus of 470,000 words and breaking them into syllables, I have cr

Re: Grep through a log file

2006-11-09 Thread ppp ppp
Hi All ; I am new to this group.I am just started to learn perl.I want to program in perl or C that it input text file(.txt) and it should find every Uppercase letters(Capital letter) in the input file converts every capital letter say with one letter d and lower case letters(small letter

Re: Grep through a log file

2006-11-09 Thread John W. Krahn
ppp ppp wrote: > Hi All ; Hello, > Subject: Re: Grep through a log file It doesn't look like you are replying to the OP and your question is not about 'grep' so you should start a new thread instead of replying to an existing one. > I am new to this group.I am just

Re: Grep through a log file

2006-11-09 Thread Mazhar
On 11/10/06, ppp ppp <[EMAIL PROTECTED]> wrote: Hi All ; I am new to this group.I am just started to learn perl.I want to program in perl or C that it input text file(.txt) and it should find every Uppercase letters(Capital letter) in the input file converts every capital letter say with one l

Re: Grep through a log file

2006-11-09 Thread ppp ppp
Hi All ; I am new to this group.I am just started to learn perl.I want to program in perl or C that it input text file(.txt) and it should find every Uppercase letters(Capital letter) in the input file converts every capital letter say with one letter d and lower case letters(small letter

Re: Grep through a log file

2006-11-09 Thread mlist
> > Matt, > > The problem is that has already returned EOF. The next > time around, Perl says "nothing more to see here, folks; move along" > and exits the while block. If you want to read from it again, you need > to reopen it. Just put the open inside the while () block. > That did it, than

Re: Grep through a log file

2006-11-09 Thread Jay Savage
On 11/9/06, mlist <[EMAIL PROTECTED]> wrote: First, thanks for your input Jay, Rob, Lawrence Jay, I tried your script. What happens is it gets through the first iteration of the script and copies the appropriate lines to the new log file. But each subsequent iteration is skipped over. This

Re: Grep through a log file

2006-11-09 Thread mlist
> Matt, > > A couple of things here. first, you don't perform any modification of > $culist, but the strings in $culist don't appear unmodified in the log > file. the string perl reads into $_ from a file like you're example is > e.g. "SUN9-GT:\n". The string in the log file, though, is just > "SU

Re: Grep through a log file

2006-11-09 Thread Jay Savage
On 11/9/06, mlist <[EMAIL PROTECTED]> wrote: I hope this is an easy one (I have a feeling it is). I'm trying to parse through a single, large firewall log file. I need to run through a file to get the firewall name and push the associated data to it's own log file. This is what I have so far:

Re: Grep through a log file

2006-11-09 Thread Rob Coops
Hi Matt, Had a look at this script but it just confused me a bit. So I wrote this that does what you want but works in a slightly diffrent way (end result is the same though) #!/usr/bin/perl use warnings; use strict; # First we make a list of what we want to find my @List; open CULIST, "CULIS

Re: Grep through a log file

2006-11-09 Thread lawrence
> I hope this is an easy one (I have a feeling it is). > > I'm trying to parse through a single, large firewall log file. I need > to run through a file to get the firewall name and push the associated > data to it's own log file. This is what I have so far: > > > #!/usr/bin/perl > > use warn

Re: Grep a variable

2006-05-19 Thread Jay Savage
On 5/19/06, Umesh T G <[EMAIL PROTECTED]> wrote: Hi List, I am trying to grep a variable from a scalar value. Here is the example below. $var = "mydisk"; $line = "mydisk is bad"; if (grep/\$var/,$line) { print "disk is not bad"; } [snip] TIA, Cheers, Umesh As others have pointed out,

Re: Grep a variable

2006-05-19 Thread Ricardo SIGNES
* Umesh T G <[EMAIL PROTECTED]> [2006-05-19T08:54:17] > I am trying to grep a variable from a scalar value. Here is the example > below. > > $var = "mydisk"; > $line = "mydisk is bad"; > if (grep/\$var/,$line) { >print "disk is not bad"; > } The simplest answer, already given, is that you sh

RE: Grep a variable

2006-05-19 Thread Ryan Frantz
> -Original Message- > From: Umesh T G [mailto:[EMAIL PROTECTED] > Sent: Friday, May 19, 2006 8:54 AM > To: Perl Beginners > Subject: Grep a variable > > Hi List, > > I am trying to grep a variable from a scalar value. Here is the example > below. > > $var = "mydisk"; > $line = "mydisk

Re: Grep frustration

2006-03-11 Thread Jay Savage
On 3/10/06, John W. Krahn <[EMAIL PROTECTED]> wrote: > Jay Savage wrote: > > > > I've actually found it depends partly on architecture, too; the regex > > engine seems better optimized on some platforms than others. I was > > quite surprised once when benchmarking a script on a fairly modern OS > >

Re: Grep frustration

2006-03-10 Thread John W. Krahn
Jay Savage wrote: > > I've actually found it depends partly on architecture, too; the regex > engine seems better optimized on some platforms than others. I was > quite surprised once when benchmarking a script on a fairly modern OS > X/PPC machine (750MHz CRT iMac) and an ancient Linux box (166MH

Re: Grep frustration

2006-03-10 Thread Jay Savage
On 3/9/06, Tom Phoenix <[EMAIL PROTECTED]> wrote: > On 3/9/06, Brian McKee <[EMAIL PROTECTED]> wrote: > > > What is a pattern match good for if it isn't for finding a substring > > in a string? > > That's a fair question. A pattern match finds a match for a pattern, > not a substring. Patterns can

Re: Grep frustration

2006-03-10 Thread John W. Krahn
Tom Phoenix wrote: > On 3/10/06, Jay Savage <[EMAIL PROTECTED]> wrote: > >>Are the two shorter matches more efficient than a single one >>for some reason? > > Probably; smaller, simpler patterns give the regular expression engine > more room for optimizations. The order of the two patterns may al

Re: Grep frustration

2006-03-10 Thread Tom Phoenix
On 3/10/06, Jay Savage <[EMAIL PROTECTED]> wrote: > Are the two shorter matches more efficient than a single one > for some reason? Probably; smaller, simpler patterns give the regular expression engine more room for optimizations. The order of the two patterns may also make a difference, but any

Re: Grep frustration

2006-03-10 Thread Jay Savage
On 3/9/06, John W. Krahn <[EMAIL PROTECTED]> wrote: > Brian Poellnitz wrote: > > > > The sample data below is read into a list, @dir_files. What I'd like > > to do is grep() the list so that I'm left with only files that end in > > ".wav" and contain certain string. The "certain string" is where

Re: Grep frustration

2006-03-09 Thread John W. Krahn
Brian Poellnitz wrote: > > The sample data below is read into a list, @dir_files. What I'd like > to do is grep() the list so that I'm left with only files that end in > ".wav" and contain certain string. The "certain string" is where I > run into problems. Something like > > grep(/.*\.wav/) >

Re: Grep frustration

2006-03-09 Thread Tom Phoenix
On 3/9/06, Brian McKee <[EMAIL PROTECTED]> wrote: > What is a pattern match good for if it isn't for finding a substring > in a string? That's a fair question. A pattern match finds a match for a pattern, not a substring. Patterns can have metacharacters, they can be case-insensitive, they can be

Re: Grep frustration

2006-03-09 Thread Brian McKee
On 09/03/06, Tom Phoenix <[EMAIL PROTECTED]> wrote: > Although it's tempting to use a pattern match for this, that's not the > right tool for the job. To see whether a string contains a given > substring, check whether the return value of index() is not -1. Can you expand on that thought? What is

Re: Grep frustration

2006-03-09 Thread Tom Phoenix
On 3/9/06, Brian Poellnitz <[EMAIL PROTECTED]> wrote: > The sample data below is read into a list, @dir_files. What I'd like to do > is grep() the list so that I'm left with only files that end in ".wav" and > contain > certain string. The "certain string" is where I run into problems. Somethi

RE: Grep frustration

2006-03-09 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Brian Poellnitz wrote: > OK here goes... > > The sample data below is read into a list, @dir_files. What I'd like > to do is grep() the list so that I'm left with only files that end in > ".wav" and contain certain string. The "certain string" is where I > run into problems. Something like >

Re: grep mystery / What happened to my @ sign ?

2005-11-23 Thread John W. Krahn
Jay Savage wrote: > On 11/23/05, Jeremy Kister <[EMAIL PROTECTED]> wrote: >>On 11/23/2005 2:26 AM, David Gilden wrote: >>>$SendersEmail ="[EMAIL PROTECTED]"; >>> >>>($SendersEmail) = $SendersEmail =~ m/([EMAIL PROTECTED],60})/; >>[...] > > You want to be careful with your classes here. '@' is no

Re: grep mystery / What happened to my @ sign ?

2005-11-23 Thread Jay Savage
On 11/23/05, Jeremy Kister <[EMAIL PROTECTED]> wrote: > On 11/23/2005 2:26 AM, David Gilden wrote: > > $SendersEmail ="[EMAIL PROTECTED]"; > > > > ($SendersEmail) = $SendersEmail =~ m/([EMAIL PROTECTED],60})/; > [...] > > I was expecting this: [EMAIL PROTECTED] > > What happened to my @ sign ? > >

Re: grep mystery / What happened to my @ sign ?

2005-11-22 Thread Jeremy Kister
On 11/23/2005 2:26 AM, David Gilden wrote: > $SendersEmail ="[EMAIL PROTECTED]"; > > ($SendersEmail) = $SendersEmail =~ m/([EMAIL PROTECTED],60})/; [...] > I was expecting this: [EMAIL PROTECTED] > What happened to my @ sign ? you'll notice that not only is the @ missing, but '@earthlink' is mis

Re: grep help request -- data fields max size

2005-10-28 Thread David Gilden
Thanks Jay, For your recommendation, is there a way I can limit the size, something like: [\w\.-]{1,50} or should I do that I bring in the data for first time? Have a great weekend! Dave Ft. Worth, Tx [ www.coraconnection.com ] > It's going to be a whole lot easier, and probably just as fast

Re: grep help request

2005-10-28 Thread John Doe
David Gilden am Freitag, 28. Oktober 2005 20.55: > Hello, > > I am stuck with this issue. > How do get each substring (the names in this case) and then upper case > them. This does not work just yet > > Possible data: > mike smith > john h. hamilton > g. bush > hendric > > etc.. > > >

Re: grep help request

2005-10-28 Thread Jay Savage
On 10/28/05, David Gilden <[EMAIL PROTECTED]> wrote: > Hello, > > I am stuck with this issue. > How do get each substring (the names in this case) and then upper case them. > This does not work just yet > > Possible data: > mike smith > john h. hamilton > g. bush > hendric > > etc.. >

Re: Grep uniqueness issue

2005-07-29 Thread Tom Allison
Ankur Gupta wrote: [EMAIL PROTECTED] wrote: Hey Guys I am having an odd problem using grep to ensure an array only contains distinct entries. I have a list similar to the following in a file (short example of a much longer list) support01-FastEthernet1/0 suppor

RE: Grep uniqueness issue

2005-07-29 Thread Ankur Gupta
[EMAIL PROTECTED] wrote: > Hey Guys > > I am having an odd problem using grep to ensure an array only > contains distinct entries. > > I have a list similar to the following in a file (short example of a > much longer list) > > support01-FastEthernet1/0 > support01-R

Re: Re: Grep uniqueness issue

2005-07-29 Thread jason_normandin
ate: 2005/07/29 Fri AM 11:32:15 EDT > To: [EMAIL PROTECTED] > CC: beginners@perl.org > Subject: Re: Grep uniqueness issue > > On Jul 29, [EMAIL PROTECTED] said: > > > I am having an odd problem using grep to ensure an array only contains > > distinct entries. > >

Re: Grep uniqueness issue

2005-07-29 Thread Jeff 'japhy' Pinyan
On Jul 29, [EMAIL PROTECTED] said: I am having an odd problem using grep to ensure an array only contains distinct entries. You should probably use a hash (along with your array, if you need to keep the order they're in) to ensure unique-ness. support01-FastEthernet1/0 support01-RH jnorman

Re: Re: Grep uniqueness issue

2005-07-29 Thread jason_normandin
Unfortunately I cannot as this is a cross-platform implementation. I need to avoid using any OS dependant commands. > > From: Eric Walker <[EMAIL PROTECTED]> > Date: 2005/07/29 Fri AM 11:19:16 EDT > To: beginners@perl.org > CC: [EMAIL PROTECTED] > Subject: Re: Grep uniqu

Re: Grep uniqueness issue

2005-07-29 Thread Eric Walker
can you use the uniq command? On Friday 29 July 2005 09:03 am, [EMAIL PROTECTED] wrote: > Hey Guys > > I am having an odd problem using grep to ensure an array only contains > distinct entries. > > I have a list similar to the following in a file (short example of a much > longer list) > > support

Re: Grep or regex

2005-02-16 Thread EWALKER 1016705
On Wednesday 16 February 2005 10:36 am, Tyson Sommer wrote: > I need to iterate over a list of data to extract a line that matches a > pattern that I have set in a variable. Is there any way to use variable > substitution within a regular expression? So far, this is all I have been > able to get to

RE: grep, and push to array if item not found

2004-10-20 Thread Steve Bertrand
> Steve Bertrand wrote: >> > Steve Bertrand wrote: >> > > I got it... >> > > >> > > for my $item (@clean) { >> > > if (! grep ($_ eq $item, @array)) { >> > > push (@array, $item); >> > > print "$item\n"; >> > > } >> > > } >> > >> > FWIW, this is a FAQ

RE: grep, and push to array if item not found

2004-10-20 Thread Bob Showalter
Steve Bertrand wrote: > > Steve Bertrand wrote: > > > I got it... > > > > > > for my $item (@clean) { > > > if (! grep ($_ eq $item, @array)) { > > > push (@array, $item); > > > print "$item\n"; > > > } > > > } > > > > FWIW, this is a FAQ (see "perl

RE: grep, and push to array if item not found

2004-10-20 Thread Steve Bertrand
> Steve Bertrand wrote: >> I got it... >> >> for my $item (@clean) { >> if (! grep ($_ eq $item, @array)) { >> push (@array, $item); >> print "$item\n"; >> } >> } > > FWIW, this is a FAQ (see "perldoc -q duplicate"). If the array > elements can > be c

RE: grep, and push to array if item not found

2004-10-20 Thread Bob Showalter
Steve Bertrand wrote: > I got it... > > for my $item (@clean) { > if (! grep ($_ eq $item, @array)) { > push (@array, $item); > print "$item\n"; > } > } FWIW, this is a FAQ (see "perldoc -q duplicate"). If the array elements can be compared with str

Re: grep, and push to array if item not found

2004-10-20 Thread Steve Bertrand
> Hi all, > > I am practicing using grep, but have a problem. Instead of directly > building an array in a traditional format with grep: > > @array = (grep $_, @input); > > I want to push items into a new array that DO NOT appear within the > current array being grepped for. Hence: > > use strict;

RE: Grep Weirdness

2004-10-07 Thread Bob Showalter
Kent, Mr. John (Contractor) wrote: ... > my(@ACTIVE) = qw {gid240 gid278 gid301}; > my(@LOGGED) = qw {gid306 gid240 gid278 gid301}; > > # This doesn't work, finds a match for every item in > # LOGGED, seems to be matching on "gid" but ignoring the number > foreach (@LOGGED){ > unless (grep /$

Re: Grep Weirdness

2004-10-07 Thread JupiterHost.Net
Kent, Mr. John (Contractor) wrote: Greetings, Hello, Encountering some unexpected behavior illustrated in the code snippet below. In the first foreach loop Seems like when I check for a match between gid306 and the contents of the the ACTIVES array I get an erroneous hit. But as shown in the secon

Re: Grep Weirdness

2004-10-07 Thread Gunnar Hjalmarsson
Mr. John Kent wrote: Encountering some unexpected behavior illustrated in the code snippet below. In the first foreach loop Seems like when I check for a match between gid306 and the contents of the the ACTIVES array I get an erroneous hit. Is this a bug in Perl or in my understanding? You missed

RE: grep in perl

2004-07-16 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Help a perl newbie coding for a bioinfo guy please. > > I have a shell script that contains the following code > > # $1=sequence_file, $2=input_file, $3=output file, $4=chain. > > if [ $# != 4 ] > then > echo "Usage: parse_pdb.sh sequence_file pdb_file output_f

Re: grep in perl

2004-07-15 Thread Gunnar Hjalmarsson
[EMAIL PROTECTED] wrote: Help a perl newbie coding for a bioinfo guy please. You appear to have misunderstood the purpose of this list. It's *not* a "write my Perl program for me for free" list. If you want to learn Perl: http://learn.perl.org/ If you want somebody who does the work for you:

RE: Grep on a ms word document

2003-11-19 Thread chetak.sasalu
. -Original Message- From: Rob Dixon [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 04, 2003 10:17 PM To: [EMAIL PROTECTED] Subject: Re: Grep on a ms word document Chetak Sasalu M wrote: > > Does anybody know of a tool which can do a grep -c > "HowManyTimesDoesThisOccur&

Re: Grep on a ms word document

2003-11-04 Thread Rob Dixon
Chetak Sasalu M wrote: > > Does anybody know of a tool which can do a grep -c > "HowManyTimesDoesThisOccur" on an ms word document. > There is a tool called powergrep but it aint free :-( Hi Chetak. Within Perl on Windows the obvious way is to export the document from Word into plain text format

RE: grep argument list too long...how to get around it?

2003-10-11 Thread Darin McBride
Luke Bakken wrote: > Rather than calling > > egrep REGEX really long list of files ... > > they should be calling (ksh here, use "echo" instead of "print" for other > shells): > > print really long list of files | xargs egrep REGEX IMO, they should be using glob and coding the grep themselves

  1   2   >