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